0

When I run the ps command i get a warning saying "Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ"

How do i suppress this warning? Is there some system setting that i must do for this. The command that i fire is :

[root@localhost home]# ps -aux | grep "curl -s -o Test" 

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root      4856  0.0  0.0   4044   672 pts/0    S+   07:20   0:00 grep curl -s -o Test
[root@localhost home]# 

Note that I have to fire the exact same command as above. That is why i am looking for some system setting that will suppress the warning.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
user2318314
  • 113
  • 2
  • 12

2 Answers2

2

From the FAQ:

Why does "ps -aux" complain about a bogus '-'?

According to the POSIX and UNIX standards, the above command asks to display all processes with a TTY (generally the commands users are running) plus all processes owned by a user named "x". If that user doesn't exist, then ps will assume you really meant "ps aux". The warning is given to gently break you of a habit that will cause you trouble if a user named "x" were created.

On my system, where a user x does not exist, I get no warning message. Therefore one can surmise that, on your system, a user named x exists.

If you can remove user x you can probably get the warning to go away. If not, you are stuck with the warning message.

Community
  • 1
  • 1
Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • 1
    I checked the /etc/passwd file. I do not have a user with username x on my system. – Rishabh Aug 20 '14 at 19:50
  • 1
    My system has procps-3.2.8... maybe the behavior is slightly different with the newer version. – Jim Garrison Aug 21 '14 at 01:12
  • I was using `-f` (full format) and on RHEL6 it was complaining about a bogus `-`, which since it doesn't complain on RHEL7, would appear to be a bogus bogus `-` warning. – Rich May 03 '18 at 00:07
0

Try:

 ps -aux | grep "curl -s -o Test" 2> /dev/null

Or a variant of that.

Tango Bravo
  • 3,221
  • 3
  • 22
  • 44
  • I cannot change the command that I am firing. i.e. I cannot append anything to it. – user2318314 Aug 20 '14 at 19:32
  • 1
    You should ask on one of the Linux stack exchanges, you'll get better help. Except everyone will yell at you for running as root. (: – Tango Bravo Aug 20 '14 at 19:38
  • 1
    That sends the `STDERR` (2) of `grep` to `/dev/null`, not the `STDERR` of `ps`. But anyway, you shouldn't promote grepitis: `ps -fC curl` will do the job. Man, `man man`, man. And yes, @Tim every sysadmin will yell at every developer for running unprivileged code as a privileged user. https://en.wikipedia.org/wiki/Principle_of_least_privilege – Rich May 03 '18 at 00:10
  • @Rich I'm well aware of the PLP, hence my comment about running things as root. Also, regarding "promoting grepitis", I wasn't. OP said that he couldn't modify the command that was run, which had already contained the grep. I was merely trying to help him get around it with a redirect. – Tango Bravo May 03 '18 at 03:43