Error msg when running ps -awx on RedHat linux under sh

I am trying to do a simple ps to get a process id in /bin/sh in RedHat Linux and am getting the error:

  "Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ"

Here is a sample script:

  #!/bin/sh

  PID=`/bin/ps -awx | grep coda | grep -v grep | /bin/awk '{ print $1}'`;
  echo "PID is: $PID"

but it DOES print out the proper PID...

What is the issue with this error and how can I get rid of it?

Thanks
-James
LVL 1
James TalvyAsked:
Who is Participating?
 
Seth SimmonsConnect With a Mentor Sr. Systems AdministratorCommented:
get rid of the - after ps
just ps awx
0
 
James TalvyAuthor Commented:
Yes... silly me to ask the question and THEN do the google...

Didn't even occur to me since I have been using UNIX for 20 years and ps -aef doesn't yield this error.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.