Solved

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

Posted on 2004-09-02
6
403 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 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

739 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