#include /* perlcr.c -- by Chris Candreva Aug 25 2000 v 0.1 -- It's a single printf -- how many versions do you want ?? Questions -- IT'S A PRINTF !!! What more do you want to know ? :-) This program is designed to be named perl -- as in what is run if someone uploads a perl script from a DOS/WIN machine in binary mode. It prints out some helpful hints on what they did wrong. I save this file as /usr/local/bin/perlcr , then create a symlink with /usr/local/bin as the pwd using this little piece of perl: #!/usr/local/bin/perl $m=chr(13); system ( "ln -s ./perlcr ./perl$m" ); History: v0.0 Aug 2000 Initial version, one big multiline printf v0.1 Nov 11, 2003: Multiline-Strings are no longer allowed in gcc. Changed to many individual "...\n"\ lines Add a different print if no command line option is passed. Otherwise we would segfault. */ main (int argc, char **argv) { if (argc < 2) { printf ("\n This program should be linked as \"perl\". In this way it will be invoked\n"\ "by any script uploaded in binary mode from a windows machine.\n\n"); exit(0); } printf ("Content-type: text/html\n"\ "\n"\ "Invalid Script Format\n"\ "\n"\ "\n"\ "

Error in script:

\n"\ "

%s

\n"\ "\n"\ "Your script can not be run, probably because it is in the Windows text file\n"\ "format. This usually happens with a script uploaded from a Windows machine.\n"\ "

\n"\ "\n"\ "If you are using FTP to send your files to the server, Perl scripts should\n"\ "be transfered in ASCII mode, not binary. WS-FTP has an Automatic mode, where\n"\ "it will attempt to automatically determine what type to use for a file.\n"\ "

\n"\ "\n"\ "From a Unix command prompt, you may also use the command: dos2unix\n"\ "infile outfile to convert a file from DOS to Unix format. If the\n"\ "infile and outfile are the same, it will write the output back\n"\ "out to the same file. File permissions, however, will then be wrong and\n"\ "should be reset.

\n"\ "\n"\ "\n"\ "\n" , argv[1]); }