Shell script error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script error
# 1  
Old 05-09-2015
Shell script error

I have wrriten a shell script and getting a below error.


Code:
ps -ef | grep "Exp" | mailx -s " Instance Currently Running Before Stop" abi@pepsi.com
mailx -s "webshell instance will be stopped now" abi@pepsi.com < /dev/null
PATH=/usr/local/bin/
cd $PATH
sudo /oes/oracle stop

cd
 
date
ps -ef | grep "Exp" | mailx -s "Instance Currently Running After Stop" abi@pepsi.com
 
cd $PATH
sudo /oes/6.3.4/olap/bin/express start
 
cd
 
mailx -s "instance has been started now" abi@pepsi.com< /dev/null
ps -ef | grep "Exp" | mailx -s "Instance Currently Running After Start" abi@pepsi.com

error :

Code:
/home/pepsi.sh[35]: mailx:  not found
+ grep Exp
/home/pepsi.sh[37]: grep:  not found
+ mailx -s OSA Instance Currently Running After Start abi@gmail.com
+ ps -ef
/home/efsoesvr/osa.sh[37]: ps:  not found
/home/efsoesvr/osa.sh[37]: mailx:  not found


I am not sure what is wrong. can u help me out
# 2  
Old 05-09-2015
When this script is running $PATH does not include the directory (or directories) where the utilities grep, mailx, and ps are located on your system.
# 3  
Old 05-09-2015
can you plz let me know how to find those utilities location of grep,mailx,ps ?
# 4  
Old 05-09-2015
Depending on what your system is, use whereis grep or type grep or locate grep or other equivalent commands.

In your above code snippet, your hopping to and fro between directories. While this is not an error, it is unnecessary as you are using absolute paths for your commands, and output files should definitely NOT go to e.g. /usr/local/bin/. Maybe your entire PATH redefinition is unnecessary?

Last edited by RudiC; 05-10-2015 at 02:53 AM.. Reason: typo
# 5  
Old 05-09-2015
this reside in PATH variable. I can able to start/stop only on that path variable.

Code:
 
sudo /oes/oracle stop => PATH=/usr/local/bin/

do I need to include the grep, ps location in my script.

Last edited by Don Cragun; 05-09-2015 at 08:17 AM.. Reason: Fix closing CODE tag.
# 6  
Old 05-09-2015
The PATH variable should NEVER be used to pass a pathname to a script nor be used within a script as a general variable holding a pathname.

The PATH variable has a very special meaning to any shell based on Bourne shell syntax (including all shells that conform to the IEEE and ISO POSIX standards and The Open Group's Single UNIX Specifications); it is a colon separated list of directories containing the utilities to be executed by that shell that are invoked with no slash characters in their pathname.

If you are saying that you want the normal setting of $PATH to find grep, ps, and mailx and need to add /usr/local/bin to find sudo;
either:
  • set PATH using PATH="/usr/local/bin:$PATH", or
  • leave PATH alone and change the invocation of sudo to /usr/local/bin/sudo /oes/oracle stop.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script with sql script error

Hi All when I execute from psql prompt, I get the result, when I try to automate using a shell script, the query is not working # `/usr/bin/psql -U postgres -d coba1 -c "select name from users where "Date" > current_date - 30;"` ERROR: column "Date" does not exist LINE 1: select... (2 Replies)
Discussion started by: srilinux09
2 Replies

2. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

3. Shell Programming and Scripting

Error in calling a shell script from another script

HI, We are using two shell scripts, script.sh,env.sh, where env.sh will be called inside script.sh. The variable inside env.sh is used as $var in script.sh.But while running the script its not identifying that variable. Is there any permission needed to call a script inside another script. ... (3 Replies)
Discussion started by: banupriyat
3 Replies

4. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

5. Shell Programming and Scripting

Error in Shell script

Hello All, I am newbe to scripting and have just taken over following script from previous developer. I am getting following error when running the script. line 70: syntax error near unexpected token `do Could some help me to rectify the error please. Thanks in advance for your... (9 Replies)
Discussion started by: Pahadia
9 Replies

6. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

7. Shell Programming and Scripting

Shell script error

Hi, I have the following table in MYSQL: (the structure looks broken in this forum but if you copy/paste it into notepad, it'll look right): +----------------------------+-----------------------+------+-----+---------+----------------+ | Field | Type |... (0 Replies)
Discussion started by: tezarin
0 Replies

8. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

9. UNIX for Dummies Questions & Answers

error in shell script

Hi, I have written a small shell script which logs into each oracle database on the server and displays whether it is in archivelog mode or not.. The script is as under: #!/bin/bash dblist=`ps -ef | grep smon | grep -v grep |cut -d'_' -f3` for ohome in $dblist; do sqlplus -s /nolog <<... (2 Replies)
Discussion started by: jalpan.pota
2 Replies
Login or Register to Ask a Question