Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a script with non-standard #! line

Status
Not open for further replies.

msc0tt

IS-IT--Management
Jun 25, 2002
281
CA
Here's a curiosity:

I have a script (myscript) like so:
#!/usr/local/bin/myprog.pl
# some data
# some more data

The Perl script (myprog.pl) looks like so:
#!/usr/local/bin/perl
print "ARGV = @ARGV\n";

I wish to run myscript from a shell prompt (please don't ask why). What is *supposed* to happen is the first line of the script (myscript) defines what program to execute. It should therefore run myprog.pl (incidentally, with "myscript" as the first parameter), which in turn should execute Perl and feed it the code from myprog.pl.

Doesn't work! No output, no errors, it just returns:
$ myscript
$

If I run "$ myprog.pl hello there", I get the desired output:
ARGV = hello there

-many thanks!

Debugging note:
I wrote a C program functionally identical to myprog.pl, compiled it, and used it in myscript as follows:
#!/usr/local/bin/myprog.exe
# some data
# some more data

This works exactly as desired:
$ myscript
argv[0] = myprog.exe
argv[1] = myscript
$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top