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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

per

Status
Not open for further replies.

jjohnn

Technical User
Feb 11, 2003
43
US
I wish to run my scripts by simply invoking the filenaem at the command line in Linux. My file is set with execute permission (700), my $PATH is set to my /home/john/scripts directory (where the file lies), and my first line is #!/usr/bin/perl, which is the first listing for

$ wheris perl

when I enter
$ myscript

I get this error:
$ bash :/home/john/scripts/myscript: bad interpreter: No such file or directory

invoking the script as
$ perl myscript

works just fine.

What obvious thing am I missing?
 
This should be titled: "Permissions"
 
It looks to me that the problem is that /usr/bin/perl doesn't really exist, even if [tt]whereis perl[/tt] is telling you that. What does "type perl" tell you?
 
Make sure the script contains the shebang as the first line followed by a simple newline. I've transfered scripts to unix that I created in windows where the newlines are cr/lf's and that screws up the shebang line, claims I have a bad interpreter.

my 2 cents ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
I just checked everything again.

$ echo $PATH shows :/home/john/scripts
rxp (the script_) is set to rwx--x--x


$type perl
perl is /usr/bin/perl
my first line (no preceding spaces or newlines) is
#!/usr/bin/perl -w
followed by an empty newline

$rxp
bash: /home/john/scripts/rxp: bad interpreter: No such file or dirctory

$ls -l /home/john/scripts/rxp
-rwx--x--x 1 john john (etc...)
 
Never mind. (/user/bin/perl is not a valid path to place at the head of my file).

All is well now.
 
I did a couple Googles, and aside from the bad path to the perl binary, everyone else points at having copied from Windows to *nix/newline issues. You could try:
Warning: My perl skills are non-existant. Script backup is included, but beware!
Code:
perl -pi.bak -e 's/\n\r/\n/g' <your script>
I think that's right. Surely someone will correct me if not ;-) --
JR
 
I'm not using windows at all in this context, just Linux. My error was a lot simpler what you say.

(I'm not far enough along to make a smart mistake yet).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top