Solved

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

Posted on 2004-09-02
6
406 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
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

 
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

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 …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

617 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