LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-24-2009, 10:22 AM   #1
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Rep: Reputation: 0
Lightbulb 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.
 
Old 08-24-2009, 10:24 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Welcome to LQ

If you are in the directory, where the file is, you need to use
Code:
./sub.sh
since it is not in your path
or use the whole path to the file
Code:
/home/user/whateverdirectory/sub.sh
 
Old 08-24-2009, 10:26 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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
 
Old 08-24-2009, 12:40 PM   #4
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 08-24-2009, 01:00 PM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Please show the output from:
Code:
ls -l sub.sh
 
Old 08-24-2009, 01:03 PM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Also post this please: file sub.sh

I suspect that the sub.sh might be seen as a dos/windows file.
 
Old 08-24-2009, 01:36 PM   #7
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Command not found

The output from:
Code:
ls -l sub.sh
is;

Code:
 -rwxr-xr-x   1 nnhh     office    1837 Aug 24 12:12 sub.sh
The other script that runs perfectly though creates the following output from the same command;

Code:
 -rwxr--r--   1 nnhh     office    1201 Aug 24 10:21 sub.sh
Thanks very much for your help,

Neda.
 
Old 08-24-2009, 01:37 PM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Or you can post the contents of the script
 
Old 08-24-2009, 02:04 PM   #9
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 08-24-2009, 02:11 PM   #10
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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
Also what do you get from:
Code:
ls -lb sub.sh

Last edited by Disillusionist; 08-24-2009 at 02:37 PM.
 
Old 08-24-2009, 03:03 PM   #11
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks.

from:
Code:
file sub.sh
I get the following:
sub.sh: executable shell script

and from:
Code:
ls -lb sub.sh
I get the following;
-rwxr--r-- 1 nnhh office 1825 Aug 24 16:00 sub.sh*

Thanks,

Neda.
 
Old 08-24-2009, 03:43 PM   #12
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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
 
Old 08-24-2009, 04:35 PM   #13
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Unhappy Command not found

No renamed the file. This didn't work either. Thanks.

Any other ideas???

Thanks,

Neda.
 
Old 08-24-2009, 08:18 PM   #14
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Can you run it as root?
try
Code:
chmod 755 sub.sh
 
Old 08-25-2009, 07:53 AM   #15
neda.hd
LQ Newbie
 
Registered: Aug 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Hello,

Thanks for all your helps.

Running as a root did not help either.

What else could be wrong?

Thanks,

Neda.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell: command not found / Runs fine with "Run command" badbunny Linux - Newbie 1 01-22-2007 01:21 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM
command not found bin_shell Linux - General 3 02-15-2004 10:50 PM
Command not found HwzrHlslndr Linux - General 14 12-31-2002 07:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration