Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-09-02
6
Medium Priority
?
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 300 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 20

Assisted Solution

by:Gns
Gns earned 300 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 300 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

722 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