Good one. Makes a lot of sense. Thanks for your help.

I will read the fine manual as requested.

On Fri, 2008-10-17 at 09:32 +0000, James Attard wrote:
> Hi Andrew...
> 
> no need to strace...please do a 'man bash' as I suggested before :p 
> 
> What you're probably missing is the behaviour of the quotes `` as a
> child shell. Let me give you an example, and I'm sure you'll
> understand better:
> 
> test.sh code:
> #!/bin/bash
> 
> echo "without quotes"
> ps -ef | grep test | grep -v grep
> 
> echo "with quotes"
> echo `ps -ef | grep test | grep -v grep`
> 
> 
> test.sh output:
> 
> /tmp> ./test.sh
> without quotes
> user     22533  2074  0 11:28 pts/0    00:00:00 /bin/bash ./test.sh
> with quotes
> user 22533 2074 0 11:28 pts/0 00:00:00 /bin/bash ./test.sh 
> user 22537 22533 0 11:28 pts/0 00:00:00 /bin/bash ./test.sh
> /tmp>
> 
> You see what's happening there? The quotes execute the command in a
> subshell. Thus you have a second process running...i.e. use the -gt
> 2 ;)
> 
> james
> 
> 
> 
> On Thu, Oct 16, 2008 at 4:21 PM, Andrew Cilia <[EMAIL PROTECTED]>
> wrote:
> 
>         Veerrry Veerry close but not quite. I added a '-h' to the ps
>         and it looks good now. We still haven't figured out what is
>         wrong yet though. Header or no header, the grep would have
>         taken that out. I'm suspecting some leftover junk from procfs
>         that hasn't been cleaned out yet before ps fetches the info
>         because if you do it in steps, the problem goes away.  
>         
>         Who's going to strace this first?
>         
>         
>         
>         On Thu, 2008-10-16 at 10:18 +0200, Raphael Borg Ellul Vincenti
>         wrote:
>         
>         > Oh.... don't I luv bashisms ...
>         > 
>         > I slightly rewrote the program and will explain why
>         > 
>         > #!/bin/bash
>         > # -C just gives you a list of the processes called what are
>         > you doing which is more efficient than running multiple
>         > greps
>         > # In this case wc -l should always return at least one line
>         > since ps -C displays a header even when no processes exist
>         > cntr=$(/bin/ps -C whatareyoudoing | wc -l)
>         > #make sure cntr is not empty
>         > if [ "x$cntr" != "x" -a $cntr -gt 1 ]; 
>         > then 
>         >   zenity --info --text "Call Logger Is Already Running"
>         >   exit 1
>         > fi
>         > while true
>         > do
>         > sleep 15m
>         > NOW=`date +"%Y|%m|%d|%H|%M|%S"`
>         > echo $NOW "|" `zenity --text "Attivita' :$NOW" --entry
>         > --title "X'Qed Tagħmel Man?" --width 1000 --height 5` >>
>         > $HOME/CALLOG &
>         > done
>         > 
>         > exit 0
>         > 
>         > Did that help ?
>         > 
>         > 
>         > On Thu, Oct 16, 2008 at 10:09 AM, Andrew Cilia
>         > <[EMAIL PROTECTED]> wrote:
>         > 
>         >         Hiyall,
>         >              here's a curious one. I created a batch job
>         >         called whatareyoudoing which contains the text you
>         >         see below. It should be a simple mechanism which
>         >         asks the user what they are doing every 15 minutes
>         >         and has a safeguard so that it does not run more
>         >         than once. The problem is that the very first time I
>         >         run it, it's saying that it's running twice. This
>         >         one has stumped me. Has anyone found anything
>         >         similar??
>         >         
>         >         #!/bin/bash
>         >         cntr=`/bin/ps ax | /bin/grep whatareyoudoing
>         >         | /bin/grep -v grep | wc -l`
>         >         if [ $cntr -gt 1 ]; 
>         >         then 
>         >           zenity --info --text "Call Logger Is Already
>         >         Running"
>         >           exit 1
>         >         fi
>         >         while true
>         >         do
>         >         sleep 15m
>         >         NOW=`date +"%Y|%m|%d|%H|%M|%S"`
>         >         echo $NOW "|" `zenity --text "Attivita' :$NOW"
>         >         --entry --title "X'Qed Tagħmel Man?" --width 1000
>         >         --height 5` >> $HOME/CALLOG &
>         >         done
>         >         
>         >         
>         >         
>         >         
>         >         The information contained in this email is
>         >         confidential and may be privileged. It is intended
>         >         for the addressee only, if you are not the intended
>         >         recipient please notify the sender and delete the
>         >         email immediately. The contents of this email must
>         >         not be disclosed or copied without the senders
>         >         consent.
>         >         We cannot accept any responsibility for viruses.
>         >         Any views expressed in this message are those of the
>         >         individual sender, except where the sender
>         >         specifically states them to be the view of Philip
>         >         Toledo Limited
>         >         
>         >         
>         >         
>         >         _______________________________________________
>         >         MLUG-list mailing list
>         >         [email protected]
>         >         http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list
>         >         
>         > 
>         > 
>         > 
>         > 
>         > _______________________________________________
>         > MLUG-list mailing list
>         > [email protected]
>         > http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list
>         
>         
>         
>         The information contained in this email is confidential and
>         may be privileged. It is intended for the addressee only, if
>         you are not the intended recipient please notify the sender
>         and delete the email immediately. The contents of this email
>         must not be disclosed or copied without the senders consent.
>         We cannot accept any responsibility for viruses.
>         Any views expressed in this message are those of the
>         individual sender, except where the sender specifically states
>         them to be the view of Philip Toledo Limited
>         
>         
>         
>         
>         _______________________________________________
>         MLUG-list mailing list
>         [email protected]
>         http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list
>         
> 
> 
> 
> 
> -- 
> www.madvip.net
> 
> 
> _______________________________________________
> MLUG-list mailing list
> [email protected]
> http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list


The information contained in this email is confidential and may be privileged. 
It is intended for the addressee only, if you are not the intended recipient 
please notify the sender and delete the email immediately. The contents of this 
email must not be disclosed or copied without the senders consent.
We cannot accept any responsibility for viruses.
Any views expressed in this message are those of the individual sender, except 
where the sender specifically states them to be the view of Philip Toledo 
Limited
_______________________________________________
MLUG-list mailing list
[email protected]
http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list

Reply via email to