On 08/09/2017 05:47 PM, bruce wrote:
> trying to get the following to output
>   pgrep -f 'bash' | wc -l
> 
>   the var $xx has the cmd...
>   something's missing to allow the backtics to run the cmd..
>   if the cmd is hadcoded.run, it works..
> 
> can't see what the homer simpson "doh" moment is!

It's kind of silly to pass that through "wc". Just use the "-c"
option to pgrep:

[root@prophead ~]# ps ax | grep bash | grep -v grep | wc -l
28
[root@prophead ~]# pgrep -f bash | wc -l
28
[root@prophead ~]# pgrep -c -f bash
28

I think PHP actually tacks on a blank line when executing the stuff in a
backtick, so the "wc" value will always be 1 greater than the normal
return. That's just a guess from doing a var_dump() on the output of the
command:

        [root@prophead ~]# php -a
        Interactive shell

        php > var_dump(`pgrep -f bash | wc -l`);
        string(3) "29
        "
        php > exit
        [root@prophead ~]#

> #!/bin/bash
> #
> # ptest.sh
> #
> # use predefined variables to access passed arguments
> #
> # $1
> aa=$1
> aa='bash'
> echo $aa " pp"
> xx="pgrep -f '"${aa}"' | wc -l"
> echo $xx   <<< this dsplays the test pgrep
> echo `$xx`   <<  err msg
> echo `${xx}`  << err msg...
> 
> ## trying to get -- pgrep -f 'bash' | wc -l <<
> ## i'm getting a Usage: pgrep [....] err msg..
> _______________________________________________
> users mailing list -- users@lists.fedoraproject.org
> To unsubscribe send an email to users-le...@lists.fedoraproject.org
> 


-- 
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital    ri...@alldigital.com -
- AIM/Skype: therps2        ICQ: 226437340           Yahoo: origrps2 -
-                                                                    -
-   To understand recursion, you must first understand recursion.    -
----------------------------------------------------------------------
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org

Reply via email to