Articles from 2006

 
 

bad interpreter: No such file or directory

When my tomcat context suddenly wouldn’t start anymore I found myself scratching my head. I couldn’t figure out why the startup.sh script always threw the error

bash: ./catalina.sh: /bin/sh^M: bad interpreter: No such file or directory

After investigating for a while I found that I had two seemingly identical files. One would run fine, the other threw a “bad interpreter” error.

Apparently if a shell script gets opened and saved in notepad it will not run anymore.

A simple “dos2unix catalina.sh” fixed the problem.

In Ubuntu the dos2unix binary can be found in the tofrodos package.

Perl File IO

I was amazed to see how simple Perl makes it to read the lines of a file into an array.

#!/usr/bin/perl
open(I, “flavors.txt”);
@flavors = <I>;

With just two lines of code, you are ready to do some string munching. You can then run through the elements in the array with a loop similar to the following.

for($i=0; $i<@flavors.length; $i++) {
@flavors[i] =~ s/•//;
}

I would enjoy seeing some other ways to iterate through the array.

cURLing Google for Fun and Profit


Fatal error: Call to undefined method PEAR_Error::highlight() in /var/www/wordpress/wp-content/plugins/CodeHighlight/CodeHighlight.php on line 142