Archive | July, 2009

Turn on register_long_arrays for PHP on Plesk

Add the following lines to the vhost.conf file for the site: <directory /var/www/vhosts/acme.com/httpdocs> php_admin_value register_long_arrays On </directory> And then do: /usr/local/psa/admin/sbin/websrvmng -a -v Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post Print for later Bookmark in Browser Tell [...]

Add the following lines to the vhost.conf file for the site:

<directory /var/www/vhosts/acme.com/httpdocs>
php_admin_value register_long_arrays On
</directory>

And then do:

/usr/local/psa/admin/sbin/websrvmng -a -v

View Comments Continue Reading →

Rename file via scripted FTP

Here’s an lftp script to rename a remote file vi FTP without downloading the file: #!/bin/bash NAS_HOST=myhost NAS_USER=myuser NAS_PASS=mypass SRC=$1 DST=$2 lftp -c “open -e \”mv $SRC $DST\” -u $NAS_USER,$NAS_PASS $NAS_HOST” Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this [...]

Here’s an lftp script to rename a remote file vi FTP without downloading the file:

#!/bin/bash

NAS_HOST=myhost
NAS_USER=myuser
NAS_PASS=mypass

SRC=$1
DST=$2

lftp -c "open -e \"mv $SRC $DST\" -u $NAS_USER,$NAS_PASS $NAS_HOST"
View Comments Continue Reading →

Perl – Sort associative array by value

Here’s an alpha sort of the values of the associative array named “myarray”: foreach my $key (sort {$myarray{$a} cmp $myarray{$b}} keys %myarray) { print “$key : ” . $myarray{$key} . “\n”; }; And here’s the same sort numerically: foreach my $key (sort {$myarray{$a} $myarray{$b}} keys %myarray) { print “$key : ” . $myarray{$key} . “\n”; [...]

Here’s an alpha sort of the values of the associative array named “myarray”:

foreach my $key (sort {$myarray{$a} cmp $myarray{$b}} keys %myarray) {
        print "$key : " . $myarray{$key} . "\n";
};

And here’s the same sort numerically:

foreach my $key (sort {$myarray{$a} <=> $myarray{$b}} keys %myarray) {
        print "$key : " . $myarray{$key} . "\n";
};

And if you want numeric descending:

foreach my $key (sort {$myarray{$b} <=> $myarray{$a}} keys %myarray) {
        print "$key : " . $myarray{$key} . "\n";
};
View Comments Continue Reading →

Remote access via ssh with RedHat Rescue Disk

Insert Rescue Disk and boot server. At the first prompt type “linux rescue” and hit enter. Follow boot disk prompts to start networking. Enter the system’s ip address, netmask, gateway and name server. Continue with prompts until the root partition is mounted and you get a command prompt. Verify network configuration with ifconfig and route. [...]

  1. Insert Rescue Disk and boot server.
  2. At the first prompt type “linux rescue” and hit enter.
  3. Follow boot disk prompts to start networking. Enter the system’s ip address, netmask, gateway and name server.
  4. Continue with prompts until the root partition is mounted and you get a command prompt.
  5. Verify network configuration with ifconfig and route.
  6. Use the following commands to start sshd:
    cd /mnt/sysimage
    chroot /mnt/sysimage
    mount /dev/pts
    /sbin/service sshd start
    

You should now be able to SSH into the server.

View Comments Continue Reading →