Click to See Complete Forum and Search --> : Running a script : No Such File or Directory error
fdpluscom
07-24-2002, 01:50 PM
Greetings,
I'm trying to run a script and I get a "No such file or directory" message. I check the name and it's correct in fact if I go back and put ls in front of the same name, I find it. So I'm sure not making a typo.
I'm logged in as root
and the owner and group for the script is root, the permission is at 755 which makes it executable.
Thank you.
lpahdoco
07-24-2002, 02:52 PM
Not sure I'm following -- you're trying to run a cgi script? If so, is it in your script directory as defined in your Virtual Host document? And you're calling it with something like www.yourdomain.com/cgi-bin/scriptname.cgi?
chikn
07-24-2002, 04:10 PM
If the script isnt in your path (usually /usr/bin, /usr/sbin) then you must prefix it with a ./ (thats a period in front of that forward slash)
fdpluscom
07-24-2002, 04:24 PM
It's a bash script to start tomcat. I actually go to the directory and run it using ./startup.sh, I try executing from within another script by pointing to the full path /usr/java/tomcat/bin/startup.sh. I get the same error.
Here is one of the scripts, the catalina.sh script is also doing the same thing.
startup.sh
--------------------------------------------------------------------
#!/bin/bash
# resolve links - $0 may be a softlink
PRG="$0"
echo "I'm here --> 001 <--"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done
echo "I'm here --> 002 <--"
PRGDIR=`dirname "$PRG"`
EXECUTABLE=`catalina.sh`
echo "I'm here --> 003 <--"
# Check that target executable exists
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
echo "Cannot find $PRGDIR/$EXECUTABLE"
echo "This file is needed to run this program"
exit 1
fi
echo "I'm here --> 004 <--"
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
------------------------------------------------------------------------
Thank you.
mingshun
07-24-2002, 10:49 PM
Originally posted by fdpluscom
It a bash script to start tomcat.
I have setup tomcat half a year ago and I couldn't remember the
exact steps. As far as I remember, you need to point your
variable (cannot remember variable name) to some path. It is
documented in the README. Did you do that?
fdpluscom
07-24-2002, 11:22 PM
Yes,
TOMCAT_HOME=/..."
CATALINA_HOME="/..."
etc..
This message is really a weird one. I checked the permissions again to verify that it is indeed executable. when I do a ls -s in the directory, all the scripts are coming up with chmod 755 (-rwxr-x-r-x) as expected.
evilcartman
07-25-2002, 11:54 AM
If the files are there, this error means that the program thats invoked by bash script is compiled with different ( incompatible ) glibc thats on your system.
Golden_Eternity
07-25-2002, 11:58 AM
I've also come across that error after transferring a shell script from a windows machine... Instead of the unix CR, it had CR-LF. I stripped out the line feeds with tr, and problem was solved.
Does it just say "no such file or directory"? or does something proceed that? Usually, it'll say something like "bash: no such file or directory" or "bash: blah: no such ...", which can help you to pinpoint which is the issue.
fdpluscom
07-25-2002, 03:05 PM
That's exactly what it was. The crlf character was not showing up when I edit with vim on linux but when I openned the file on windows vim I saw the ^M characters. I removed them, changed the file format to write Unix instead of DOS and I was on my way.
Thank you very much. I'm now a happy man.