bash "not found" error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash "not found" error
# 1  
Old 05-02-2012
bash "not found" error

In solaris, I am using a bash script which includes the following variable declaration. The script executes successfully on the command line, but when executed through the cron, I receive a "not found" error.

Code:
amt="`echo "scale=3;$numerator/$base*100" |bc |cut -d. -f1`"

Here is the output from bash -x <script name>
Code:
May  2 20:05:11 eqewrsdbp02 md_get_all.sh[1219]: [ID 702911 local7.info] .//md01/EL/MarketData/scripts/md_get_all.sh[422]: : cannot execute
May  2 20:05:11 eqewrsdbp02 md_get_all.sh[1219]: [ID 702911 local7.info] .//md01/EL/MarketData/scripts/md_get_all.sh[422]: 0/77904740*100|bc |cut -d. -f1:  not found


Last edited by Corona688; 05-02-2012 at 05:43 PM..
# 2  
Old 05-02-2012
What does your cron entry for it look like?

What is the first line in your script?
# 3  
Old 05-02-2012
Hi,
Here is the cron entry -

Code:
5,20,35,50 * * * * /md01/EL/crons/md_get_all_wrapper.sh > /dev/null 2>&1

First line in the script is

Code:
#!/bin/bash -x

# 4  
Old 05-02-2012
I bet it can't find cut or bc due to PATH problems. cron gives an extremely minimal PATH to things it runs, many of the usual commands you'd expect from a login won't be found. Make sure you set an appropriate PATH at the beginning of your script.
# 5  
Old 05-02-2012
Ok. Would it make more sense to indicate a source in the beginning of the script like

Code:
bc=/usr/bin/bc
cut=/usr/bin/cut

or explicitly state the path in the declaration-

amt="`echo "scale=3;$numerator/$base*100" |/usr/bin/bc | /usr/bin/cut -d. -f1`"
# 6  
Old 05-02-2012
Neither, really. What would make the most sense would be fixing the value of PATH at the start of your script so it can find them properly without that rigamarole. That's what PATH is for.

If /usr/bin is the only one you need to add, then:

Code:
PATH="$PATH:/usr/bin"

# 7  
Old 05-02-2012
Ok. I tried sourcing the profile in the script like so because I figured there was something different in the cron. I will try using the code you provided.

Code:
source /etc/profile

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

3. Shell Programming and Scripting

Bash script fails with "function: not found" error

Hello everyone, I am having problems figuring this out. This script below is supposed to create a list of file names with their "md5sum", in a file "lib-list.txt" When I run it "sh component-list.sh " I get this:component-list.sh: 4: component-list.sh: function: not found component-list.sh:... (4 Replies)
Discussion started by: joemb
4 Replies

4. Shell Programming and Scripting

Bash Script giving "Command Not found"

Hello Geeks, Greetings...I have the following script: #!/usr/bin/bash #Script to generate number of active PDP context & calculate PDP activation #failurefrom EPG-M #Script written by Gbenga Adigun #September 12, 2013 username="xxxxxx" password="xxxxxxxxx" HOSTS=( ggsn01... (6 Replies)
Discussion started by: infinitydon
6 Replies

5. Shell Programming and Scripting

"Command not found" doing a while loop in bash/shell

i=0 numberofproducts=${#urls} #gets number of entries in array called "urls" numberofproductsminusone=`expr $numberofproducts - 1` #-subtract by one while do wget ${urls} i=$(( $i + 1 )) sleep 10 done I'm getting an error ./scrape: line 22: [0: command not found that... (3 Replies)
Discussion started by: phpchick
3 Replies

6. Red Hat

Could interrupt disabled cause "opreport error: No sample file found"?

Hi All I would like to profile my application with oprofile but I can't since no samples are collected. The kernel of my app is 2.6 on RED HAT Enterprise 5.3 (Tikanga) so OProfile is setup in timer interrupt mode # opcontrol --list-events Using timer interrupt. I... (0 Replies)
Discussion started by: manustone
0 Replies

7. Post Here to Contact Site Administrators and Moderators

What's happens with my thread about "-bash: ELF: command not found "?

Hi, Today, I've submitted a new tread in "Shell Programming and Scripting" forum, with title "-bash: ELF: command not found ". However, this thread has disappear. Can somebody give me an explanation? Regards. (3 Replies)
Discussion started by: Sonia_
3 Replies

8. Shell Programming and Scripting

"-bash: sqlldr: command not found"

hi all, here i am trying to run one control file. but getting "-bash: sqlldr: command not found" error :confused: the code is given below. sqlldr $db_username/$db_password@$db_sid control=$loading_path/load_to_table.ctl log=loading.log can anybody help me in fixing the issue? ... (1 Reply)
Discussion started by: vinayakatj56
1 Replies

9. Red Hat

"No Drives Found" error during Redhat Linux AS 4 installation

I'm trying to install Redhat LInux AS 4 update 4 on an IBM x306 series server. I keep getting following error: "No Drives Found. An error has occurred - no valid devices were found on which to create new file systems. Please check your hardware for the cause of this problem." I called IBM and... (2 Replies)
Discussion started by: pieman8080
2 Replies
Login or Register to Ask a Question