Command not found
Hello,
I am trying to run a shell script. The script is made executeable using both following commands; chmod +x sub.sh chmod u+x sub.sh However, when running sub.sh I receive the following; sub.sh: Command not found Would some one please help me find out what causes this? I appreciate your help. Many thanks, Neda. |
Welcome to LQ
If you are in the directory, where the file is, you need to use Code:
./sub.sh or use the whole path to the file Code:
/home/user/whateverdirectory/sub.sh |
If the script sub.sh is not in a directory included in the PATH environment variable, you have to specify the absolute or relative path on the command line. If you want to launch an executable placed in the current working directory you can simply do
Code:
./sub.sh |
Re: Command not found
Hi,
Thanks for the welecome message and your response. I am in the directory where the file is. However, even "./sub.sh" is generating the same : Command not found message. I have two similar packages that use same codes and scripts, with some deferences in input and output files and calculations. Script in one package is running perfectly but script in this second package is creating Command not found. Both scripts from both packages are the same and are using the same environment. Would you please advice? Thanks very much, Neda. |
Please show the output from:
Code:
ls -l sub.sh |
Also post this please: file sub.sh
I suspect that the sub.sh might be seen as a dos/windows file. |
Command not found
The output from:
Code:
ls -l sub.sh Code:
-rwxr-xr-x 1 nnhh office 1837 Aug 24 12:12 sub.sh Code:
-rwxr--r-- 1 nnhh office 1201 Aug 24 10:21 sub.sh Neda. |
Or you can post the contents of the script
|
Command not found
Here is the script;
#!/bin/sh . $HOME/.profile FEDS=/directory FEDSBIN=/directory/bin CRON_DIR=$HOME/cronDir . $CRON_DIR/scrubReport/MBS_ScrubReport/env.sh export HOME FEDS FEDSBIN LD_LIBRARY_PATH STARTAPP_DIR=/home/directory/bin export STRATAPP_DIR OUT_DIR=home/scrubReport/output LOG_DIR=home/scrubReport/logs #---Running subMain.cpp through scrub.sh and redirecting the output---- /bin/rm $OUT_DIR/errors_mbs.csv /bin/rm $LOG_DIR/logs_mbs.csv ${STARTAPP_DIR}/startApp -c 1 -m 4048 -w 5 -z 600 -i "server5" -s "cd cronDir/scrubReport/MBS_ScrubReport; scrub.sh">/home/scrubReport/logs/logs_mbs.csv 2>/home/scrubReport/output/errors_mbs.csv Thanks a lot, Neda. |
Hard to tell without [ CODE ] tags around the code.
There appears to be a typo: export STRATAPP_DIR and that should be on a new line, but that shouldn't cause the issue that you are reporting. What did you get from: Code:
file sub.sh Code:
ls -lb sub.sh |
Thanks.
from: Code:
file sub.sh sub.sh: executable shell script and from: Code:
ls -lb sub.sh -rwxr--r-- 1 nnhh office 1825 Aug 24 16:00 sub.sh* Thanks, Neda. |
Aha, that explains a few things.
It looks like you have a non-printing character in the file name. You need to rename the file: Code:
mv sub.sh* sub.sh |
Command not found
No renamed the file. This didn't work either. Thanks.
Any other ideas??? Thanks, Neda. |
Can you run it as root?
try Code:
chmod 755 sub.sh |
Hello,
Thanks for all your helps. Running as a root did not help either. What else could be wrong? Thanks, Neda. |
All times are GMT -5. The time now is 10:39 PM. |