Solved

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

Posted on 2014-03-18
2
944 Views
Last Modified: 2014-03-18
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
0
Comment
Question by:James Talvy
2 Comments
 
LVL 34

Accepted Solution

by:
Seth Simmons earned 500 total points
ID: 39936921
get rid of the - after ps
just ps awx
0
 
LVL 1

Author Comment

by:James Talvy
ID: 39936938
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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
linux SFTP 8 78
Powershell command 2 42
AWK: Pytthagoras bp script Part deux 22 43
WMIC Output Formatting 1 47
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question