Monday, 23 November 2009

Using sed to change perl interpreter path in scripts

Was installing OTRS on windows (unfortunately), even tho I downloaded the zip file it still used /usr/bin/perl as path and this was causing problems so wanted quick way to change #!/usr/bin/perl at beginning of each perl script into #!perl (assuming perl in is your windows path)

SED is well known and incredibly useful tool for doing such a job, easiest way to download is to install cygwin

Following test on a file will output to stdout and prove regular expression works


sed 's/^#!\/usr\/bin\/perl/#!perl/g'

after that you can use the "-i" switch to do a live edit of all files with a ".pl" extension
sed -i 's/^#!\/usr\/bin\/perl/#!perl/g' *.pl

Tried initially using "*" glob but turns out sed then tries to process directories and gives error, not all perl files have the .pl extenstion so modified slightly to use the find command to process only files and pass them to sed command.

find -type f -print -exec sed -i 's/^#!\/usr\/bin\/perl/#!perl/g' {} \;

On windows you might be best changing #!perl to be full path to your perl executabe, e.g. #!C:\/Perl\/Bin\/Perl.exe


Monday, 2 November 2009

Solaris Power On Self Tests

Had serious palpitations last Fri lunchtime,  one of our main Solaris server's had an issue with its meta disk / raid config.  It wasn't a good scenario as the 2 internal physical drives were reporting errors on the exect same slice.

Thankfully preliminary checks showed this didn't look like a physical error but to be sure and to fix removed meta disk from vfstab and replaced it with single physical disk so we could fsck the disks and clear and rebuild the meta disks (if no physical errors)

Anyway to cut long story short its been quite a while since I've worked on Sun Servers and I clean forgot that their POST checks tend to be very thorough.  When a windows server takes prob 30secs at most the V490 spends 20mins checking.  For about 15 of these 20mins I was thinking this server is finished !*?#

2 Lessons learned, a) never put a solaris server into power off, just reboot and b) if you do go of and make cup of tea and relax :-)