Solved

bash: ./script_name: No such file or directory (cheail, u there?)

Posted on 2004-09-02
6
401 Views
Last Modified: 2008-03-17
This question is related to this one:
http://www.experts-exchange.com/Operating_Systems/Linux/Q_21114579.html

The script being referred to initially won't run because the partition
on which the script was saved in did not have the exec setting enabled.

I turned the exec setting on, mounted and unmounted the file.
The funny thing is other scripts existing in the same directory can be
run successfully by bash while some cannot:

I run ./somescript.pl
the script runs successfully

I run ./anotherscript.pl, the shell returns
bash: ./anotherscript.pl: No such file or directory

If I run perl ./anotherscript.pl, the script runs successfully, so there seems to be nothing wrong with
the script.

I must be able to run the script directly from the shell since they are part of a cgi application
If I can't, httpd won't also and my cgi app wont run (error_log file also shows the same
error when calling the cgi script: No such file or directory)

Cheail, if your there, maybe you can also help me out on this one. =)
Thanks guys


0
Comment
Question by:rqs
6 Comments
 
LVL 23

Expert Comment

by:Mysidia
ID: 11970091
Check the contents of the script, look at the first line... make sure it looks like

#!/usr/bin/perl

and the path to the interpreter is correct
0
 
LVL 2

Author Comment

by:rqs
ID: 11970274
the script already refers to the correct path of the perl executable,
this is not the problem in this case but something else.


0
 
LVL 19

Accepted Solution

by:
ramazanyich earned 75 total points
ID: 11970447
It can be that your script file was saved on Windows platform. It means that CRLF is used as line terminator but in UNIX it should be only LF character. So you should convert your script to Unix style using dos2unix command:
>dos2unix script > new_script
>mv new_script script
>chmod +x script
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 20

Assisted Solution

by:Gns
Gns earned 75 total points
ID: 11970915
Hm, yes, that could well be it... You can check your first line with the command
head -1 anotherscript.pl | od -c
... If it ends with \n only all is cool, if it ends in \r\n you've got thos problem... I doubt you have a perl named perl\r :-)

-- Glenn
0
 
LVL 44

Assisted Solution

by:Karl Heinz Kremer
Karl Heinz Kremer earned 75 total points
ID: 11972165
You can also spot this problem by just opening the file in vim (which is usually aliased or linked to vi). And, you can also correct it in vi without the need for dos2unix: Replace <ctrl>M with <ctrl>M - does not sound like it's doing anything, but it works :-) There is a trick however to enter the control characters. Type the following in vi:
:1,$ s/<CTRL>V<CTRL>M/<CTRL>V<CTRL>M/g

Is the execute bit set for this file? You can force it to be set by running
chmod 755 ./anotherscript.pl
0
 
LVL 2

Author Comment

by:rqs
ID: 11986889
Thanks guys. That did it. The files were modified on my Win32 desktop before
moving it to the Linux server.

Thanks again =)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question