Cmail - C or perl or whatever
Paul O'Neill
pvo3366 at sapphire.OCE.ORST.EDU
Sat Oct 28 15:45:08 AEST 1989
In article <14810 at bfmny0.UU.NET> tneff at bfmny0.UU.NET (Tom Neff) writes:
>
>And please note that the cute device
>
> #!/usr/bin/perl [-flags]
>
>which lets some users run perl scripts directly by name as ziplessly as
>if they were standalone executables, DOES NOT WORK everywhere. On my
>system, it would be necessary to create companion shell scripts or Korn
>shell aliases to invoke any such script.
>
Perl is so cool. From the man page:
-S makes perl use the PATH environment variable to search
for the script (unless the name of the script starts
with a slash). Typically this is used to emulate #!
startup on machines that don't support #!, in the fol-
lowing manner:
#!/usr/bin/perl
eval "exec /usr/bin/perl -S $0 $*"
if $running_under_some_shell;
The system ignores the first line and feeds the script
to /bin/sh, which proceeds to try to execute the perl
script as a shell script. The shell executes the
second line as a normal shell command, and thus starts
up the perl interpreter. On some systems $0 doesn't
always contain the full pathname, so the -S tells perl
to search for the script if necessary. After perl
locates the script, it parses the lines and ignores
them because the variable $running_under_some_shell is
never true.
Tom Christiansen obviously wrote the program to show off the language, not
to do the job. Take a hint. You're not out in the cold if your vendor
didn't supply it. Scarf it, install it. You and your users will thank you.
Paul O'Neill pvo at oce.orst.edu
Coastal Imaging Lab
OSU--Oceanography
Corvallis, OR 97331 503-754-3251
More information about the Alt.sources.d
mailing list