Sam, > Hey, so I'm having a weird problem maybe someone can help me with. > I have a simple perl script named test.cgi that generates html (ie a cgi > script) which looks like > > #!/usr/bin/perl > # hello.pl -- my first perl script! > print "Content-type: text/html\n\n"; > print <<"EOF"; > <HTML> > <HEAD> > <TITLE>Hello, world!</TITLE> > </HEAD> > <BODY> > <H1>Hello, world!</H1> > </BODY> > </HTML> > EOF > > If I type "perl test.cgi" (minus the quotes) the perl script runs. If I > type "./test.cgi" I got the error "bash: ./test.cgi: No such file or > directory" > If I remove the #!/usr/bin/perl line from the beginning of the perl script > and "./test.cgi" again it runs but gives a lot of file not found errors. > I'm guessing that somewhere there is an environment variable I am missing or > something... I have perl 5.6 installed and Mandrake 7.1 with the 2.2.16 > kernel. > Any suggestions??? > > Thanks > Sam I got bitten by this in my early days of Perl on Linux... Note the output (xx.pl is your script copy/pasted into it, chmod 711)... # the following 3 commands give the same output [DW] $ perl xx.pl [DW] $ ./xx.pl [DW] $ perl xx2.pl Content-type: text/html <HTML> <HEAD> <TITLE>Hello, world!</TITLE> </HEAD> <BODY> <H1>Hello, world!</H1> </BODY> </HTML> [DW] $ ./xx2.pl bash: ./xx2.pl: No such file or directory Hey, what happened to ./xx2.pl ? [DW] $ ll xx* -rwx------ 1 dwoods dwoods 205 Oct 24 23:29 xx.pl* -rwx------ 1 dwoods dwoods 218 Oct 24 23:29 xx2.pl* -rw------- 1 dwoods dwoods 264 Oct 24 23:31 xx2.pl.zip xx.pl is your script. I uploaded it to Windows, zipped, downloaded it back (xx2.pl.zip), unzipped it to give me xx2.pl ;) Figured it out ? That's right, ftp'ing a zip file and unzipping it on Linux will retain the Windows end-of-line markers (CR/LF). *nix only uses LF (newline). If you use vi/vim on xx2.pl, you'll see a '[dos]' comment in the status line (bottom). If you use 'cat -v xx2.pl', you'll see the '^M' at the end. If you compare xx.pl and xx2.pl by using 'od =a xx.pl' and 'od -a xx.pl2', you'll see 'cr' in xx2.pl . So how do we convert it ? You could gzip your file, upload to windows, unzip it, download the unzipped file, and then ./xx2.pl will work (chmod 711). You could go to rpmfind.net and look for dos2unix.rpm (and unix2dos) files. However I prefer to do this simple trick [DW] $ tr -d '\r' <xx2.pl >xx2ok.pl [DW] $ chmod 711 xx2ok.pl [DW] $ ./xx2ok.pl Moral of the story... if you download zip files onto Linux, be sure to use unzip -a file # see: man unzip Or unzip on windows, and then your ftp program will convert line endings on text files. Thanks... Dan.
Keep in touch with http://mandrakeforum.com: Subscribe the "[EMAIL PROTECTED]" mailing list.