In article
<
262db63a-fb5c-4b4c...@i6g2000vbh.googlegroups.com>,
kc <
keec...@gmail.com> wrote:
> Hi,
>
> Could someone please help me figure out why:
> GNU bash, version 3.2.25(1)-release-(x86_64-redhat-linux-gnu)
>
> 1) Why when I do an echo, I get /bin/sh returned as well ?
>
> For example, my script below:
> #!/bin/bash
>
> SERVICE='crond'
> HOST=`hostname`
>
> content=`ps auxw | grep [c]rond| awk '{print $11}'`
> echo "CONTENT:" $content
>
> and output is:
> CONTENT: /bin/bash /bin/bash crond
>
> Why are there 2 extra arguments printed ?
What's the name of your script? Does it have "crond" in its name? Or
is "crond" one of the arguments? In either of those cases, the ps line
for the script itself will be matched by the grep.
Why not use: awk '$11 == "crond" {print $11}'
> Also how do I get rid of the "/bin/bash /bin/bash" and just have
> "crond" as output ?
Make sure the ps|grep doesn't match any bash lines.
>
> 2) I get a different output from the same script if I run snmpwalk:
> part of the script:
>
> $PLACE.1.1) echo "string"; echo `bash /directory/crond.sh`; exit 0 ;;
>
>
> STRING: "CONTENT: /bin/sh bash bash crond
>
> Why are there 3 extra arguments printed this time. Would like to just
> output "crond".
Every script that has crond in its name or arguments is going to be
matched by the grep. You need to be more specific in what you match, if
you want to exclude these.
--
Barry Margolin,
bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***