${0##*/} Grep and regular expressions

${0##*/} Grep and regular expressions

Post by human resour » Sun, 03 Aug 2003 02:57:07



Folks:

      I took over this code and am having a tough time trying to debug
this line. Basically, we have a Cron job running with a Shell script
and after the job is completed, I get the following error message as
an eMail to me

name=`id -un`
ps -fu $name | grep ${0##*/}\$ | grep -v grep | grep -v $$ > /dev/null
2>&1

Its at the above lines I get the error (as I am guessing)  and I know
that it checks for all the running processes of a given user, but I am
not sure what causes this following error to show up.

Any pointers on this would be highly appreciated

Regards,

usekar

Error message as in Mail.

id: illegal option -- u
Usage: id [user]
       id -a [user]
ps: option requires an argument -- u
usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid
        pri opri pcpu pmem vsz rss osz nice class time etime stime
        f s c lwp nlwp psr tty addr wchan fname comm args

 
 
 

${0##*/} Grep and regular expressions

Post by Adam Pric » Sun, 03 Aug 2003 03:11:34




Quote:> Error message as in Mail.

> id: illegal option -- u
> Usage: id [user]
>        id -a [user]

Solution RTFM for id.

Your version of ID does not support the -u flag or the -n flag.
This means that the variable 'name' has no value.
This leads to second error...

Quote:> ps: option requires an argument -- u
> usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
> [ -u userlist ] [ -U userlist ] [ -G grouplist ]
> [ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
>   'format' is one or more of:
> user ruser group rgroup uid ruid gid rgid pid ppid pgid sid
> pri opri pcpu pmem vsz rss osz nice class time etime stime
> f s c lwp nlwp psr tty addr wchan fname comm args

Solution RTFM for ps.
Note that ps -u requires a user.
Note that $name has no value and realise that the command cannot work as typed.

HTH
Adam