Solved

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

Posted on 2004-09-02
6
395 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 20

Assisted Solution

by:Gns
Gns earned 75 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now