Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set -A instance2 `ps -ef ¦ grep smo

Status
Not open for further replies.

InigoMontoya

IS-IT--Management
Jun 18, 2003
51
US
set -A instance2 `ps -ef | grep smon | grep -v grep | nawk -F"_" '{print $3}'`

The snippet of code above is inside a case statement for some reason i receive a syntax error when I run the script:

set -A instance2 `ps -ef | k4[82]: syntax error at line 143 : `|' unexpected

When I run the same code directly on the command line it works fine. What gives?!
 
first I suggest you change the command

set -A instance2 `ps -ef | grep smon | grep -v grep | nawk -F"_" '{print $3}'`

to

set -A instance2 `ps -ef | grep [o]ra_smon |nawk -F"_" '{print $3}'`

the [o] removes the need for grep -v

grep smon will also find eg /x/y/xasmon


Please post the code fragment that includes the grep and the case.

the | may need escaping
 
The tip with [o] works great. Thanks for that. Here's the block of code with the case statement:

case ${param} in
stop)
set -A instance2 `ps -ef | grep [o]ra_smon | nawk -F"_" '{print $3}'`
if [[ -n $instance2 ]]
then
set -A var1 `ps -ef | grep "CPMGR FNDCPMBR" | grep -v grep | nawk '{print $1}'`
if [[ -n $var1 ]]
then
function1 $instance2 $appsuser
fi
function2 $instance2
fi
;;
start)
command
command
;;
esac
 
I get no errors from this code fragment. I suspect you wouldn't either.

The cause of your error is in some other part of the script (k4[82]: syntax error at line 143 :).

Please post the entire script.


set -x
param=$1
case ${param} in
stop)
set -A instance2 `ps -ef | grep [o]ra_smon | nawk -F"_" '{print $3}'`
if [[ -n $instance2 ]]
then
set -A var1 `ps -ef | grep "CPMGR FNDCPMBR" | grep -v grep | naw
k '{print $1}'`
if [[ -n $var1 ]]
then
print 1 function1 $instance2 $appsuser
fi
print 2 function2 $instance2
fi
;;
start)
print command
;;
esac

TRACE:-

+ param=stop
+ ps -ef
+ nawk -F_ {print $3}
+ grep [o]ra_smon
+ set -A instance2 QA
+ [[ -n QA ]]
+ ps -ef
+ grep CPMGR FNDCPMBR
+ grep -v grep
+ nawk {print $1}
+ set -A var1
+ [[ -n ]]
+ print 2 function2 QA
2 function2 QA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top