[plug] Running a script to parse a script with args
James Devenish
devenish at guild.uwa.edu.au
Thu Aug 28 16:41:03 WST 2003
In message <200308281529.42759.T.Phillips at murdoch.edu.au>
on Thu, Aug 28, 2003 at 03:29:42PM +0800, Trevor Phillips wrote:
> #!/usr/bin/perl /my/perl/script some args
> data....
>
> It returns an error indicating perl is trying to run "/my/perl/script some
> args" as the script name.
That is correct. The above syntax is very limited "kludge" (it may even
have a very short line-length limit!) that most of us take for granted.
All data after the first whitespace character will be passed to perl as
a single argument (hence the error message). *Furthermore*, Perl will
actually receive command-line arguments of the script. So it is best to
avoid this syntax for anything sophisticated.
Further explanation:
If you have named script.sh that contains this:
#!/usr/bin/perl /my/perl/script some args
and you invoke script.sh as
./script.sh more args
then, IIRC, /usr/bin/perl will receive the following four
command-line arguments (I have written them ONE per line):
/my/perl/script some args
./script.sh
more
args
More information about the plug
mailing list