in reply to Re: Why do I need -w in a cgi script
in thread Why do I need -w in a cgi script

Once, in a previous lifetime, when I was a sysadmin on a server where rather clueless peopleclients were uploading Perl CGI scripts, I fixed this problem by creating a symbolic link of which the name would include the ^M. It was easier then explaining having to use ASCII FTP mode over and over and over again.
# perl -e '$a=`which perl`;symlink $a,"$a\r"'

Liz

Update:
Change symlink creation to a more Perlish way.

Update:
Changed perlish way from # perl -e 'symlink $^X,"$^X\r"' to the above, to take into account the directory where Perl resides. Pointed out by ambrus.

Replies are listed 'Best First'.
Re: Re: Re: Why do I need -w in a cgi script
by ambrus (Abbot) on Oct 10, 2003 at 10:59 UTC
     perl -e 'symlink $^X,"$^X\r"' won't work, as $^X equals to "$^X" in this case, so it will create a broken symlink named perl^M in the current directory. You'll first have to chdir to /usr/bin.
Re: Re: Re: Why do I need -w in a cgi script
by ambrus (Abbot) on Oct 17, 2003 at 11:56 UTC
    Sorry to annoy you, but I still don't like it this way. On my system, `which perl` will return "/usr/local/bin/perl", so "/usr/bin/perl\cM" will still not exist. Also, which is just an alias for type -p, so I doubt if it's portable (it might not even work if it's defined in bashrc, that's read only in interactive sessions). (Also, on some machines, /usr/local/bin/perl is a later version of perl than /usr/bin/perl.)