Visit Our UNIX and Linux User Community


#!/usr/bin/env : perl no such file or directory


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users #!/usr/bin/env : perl no such file or directory
# 1  
Old 07-24-2009
#!/usr/bin/env : perl no such file or directory

hi i have some perl scripts with shebang line as (#! /usr/bin/env perl ) instead of actual absolute path of perl ( i know why its that way ) everything works fine from command line , the problem is when i am trying to run those scripts from web ( local web tool ) it throws error as
Code:
/usr/bin/env : perl No such file or directory

even when i logged in to web user i tried to run it it was okay .... i googled for it but not getting answers only suggestions to change it to absolute path which i dont want to do. any suggestions ??
# 2  
Old 07-24-2009
What is env? What you have is a shebang where perl is some kind of parameter or option. I'm guessing you find perl because it is in your PATH when you are logged on. a more standard shebang would be
Code:
/usr/bin/env/perl

assuming this actually points to the location of the perl exectuable.
# 3  
Old 07-24-2009
It because the perl interpreter is not in the search path of the user that owns the web server process.
You could consider:

1. Modifying your shebang (to point directly to the perl interpreter), for example:

Code:
#!/usr/bin/perl

or

2. Adding the perl interpreter's directory to the search path to the user that owns the web server process and continue to use the env program:
Code:
#!/usr/bin/env perl

# 4  
Old 07-24-2009
yup you are right...
PATH variable was not passed to fastcgi when starting a apache as it was not in path it used to throw error. just passed the variables now its working ..
thanks a lot

Fun Perl Fact:

Quote:
Perl 5 is a highly capable, feature-rich programming language with over 30 years of development. Perl 6 is a sister language, part of the Perl family, not intended as a replacement for Perl 5, but as its own thing - libraries exist to allow you to call Perl 5 code from Perl 6 programs and vice versa.
# 5  
Old 10-30-2009
I would like to "dig" the subject a little bit more, because I have also problem with script using that way of shebang.
I have installed, on Solaris, system wide, Perl 5.8.7 and the script that uses env tool to launch perl interpreter looks for LibXML.pm in folders where used to be installed perl 5.8.4.
So i have two questions:
1. why one would use env tool to launch perl instead of launching perl directly?
2. how to modify the env's output?
# 6  
Old 10-30-2009
Quote:
Originally Posted by sylwesterr
[...]
1. why one would use env tool to launch perl instead of launching perl directly?
You could need to call it that way when you don't have control over the owner of the apache process and/or
you want to use the same configuration file on more non identical systems.

Quote:
2. how to modify the env's output?
If the above is not true just modify the environment of the owner of the apache process and point directly to the desired Perl interpreter.

You will use /usr/bin/env ... when you are not sure where exactly the needed executable is located, but you're sure it can be found somewhere in the environment.
# 7  
Old 10-31-2009
Hi.

These are good questions, and it is useful to know the issues. As radoulov has written, the env in the shebang line
Code:
#!/usr/bin/env bash

promotes portability. I use that in a template for writing scripts because I use several environments, and the locations of bash, ksh, perl, etc., are not consistent. This is often true for posting scripts here in this forum because the questions do not always mention the environment, Linux, Solaris, AIX, etc., so I almost always use that for suggested solutions. The Linux documentation for env leaves much to be desired in my opinion. For more information on many subjects including the use of env, see "bash Cookbook", O'Reilly, page 321.

However, we need to balance portability and security. If you have a consistent environment, then, for bash scripts, the construct
Code:
#!/bin/bash -

will avoid certain security risks. See "bash Cookbook", page 283. The authors consider the risks of the env construct to be small, so I generally stay with that.

Best wishes for safety and portability ... cheers, drl

Previous Thread | Next Thread
Test Your Knowledge in Computers #941
Difficulty: Medium
A ping of death is a type of attack on a computer system that involves sending a malformed or otherwise malicious ping to a computer.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting error: /usr/bin/env: ruby: No such file or directory

Hi, I installed ruby using rvm with root user on Linux. Now i m trying the below command as a non root user with sudo privileges. sudo /usr/local/rvm/rubies/ruby-2.2.5/bin/gem install passenger I get the below error: I had even reset the path for both gem as well as ruby as you... (8 Replies)
Discussion started by: mohtashims
8 Replies

2. Shell Programming and Scripting

Discussion: use "/usr/bin/env" or not

Hi. In thread https://www.unix.com/shell-programming-and-scripting/265878-date-format-problem.html , Aia and I were discussing the usefulness of using #!/usr/bin/env bash (or ksh, or perl, or ...) as the shebang line. The exchange was good, but it was getting beyond the scope or the thread, so I... (4 Replies)
Discussion started by: drl
4 Replies

3. BSD

FreeBSD: /usr/bin/ld not looking in /usr/local/lib

I'm not sure if this is the default behavior for the ld command, but it does not seem to be looking in /usr/local/lib for shared libraries. I was trying to compile the latest version of Kanatest from svn. The autorgen.sh script seems to exit without too much trouble: $ ./autogen.sh checking... (2 Replies)
Discussion started by: AntumDeluge
2 Replies

4. Solaris

What is the difference between xpg4/bin and usr/bin?

Hi Experts, I found that the same commands(sort, du, df, find, grep etc.) exists in both dir. What is the difference to use them? i.e: to use xpg4/bin/grep and usr/bin/grep My OS version is SunOS 5.10 Regards, Saps (7 Replies)
Discussion started by: saps19
7 Replies

5. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

6. Solaris

Solaris - /usr/bin/rm file

Hi , Can anyone tel me how to read the content of /usr/bin/rm file and pls tell me is it possible to edit that file??? (23 Replies)
Discussion started by: sudhan143
23 Replies

7. Solaris

How do I link ld in /usr/ucb/ to /usr/ccs/bin?

Hi all, below is the problem details: ora10g@CNORACLE1>which ld /usr/ucb/ld ora10g@CNORACLE1>cd /usr/ccs/bin ora10g@CNORACLE1>ln -s /usr/ucb/ld ld ln: cannot create ld: File exists ora10g@CNORACLE1> how to link it to /usr/ccs/bin? (6 Replies)
Discussion started by: SmartAntz
6 Replies

8. AIX

losing /usr/bin directory

I need help figuring out why I lose /usr/bin directory sometimes it goes down 3-4 times a day and I have to link them back using ln - /usr/bin bin I cannot figure out why this is happenning (23 Replies)
Discussion started by: smatherly
23 Replies

9. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies

Featured Tech Videos