I tried it too and got the same results as you did Rick:
grepping for 'foo' I don't see the process, but if I grep for 'sleep' 
it shows up.

Rick Meyerhoff wrote:
> Ok, got it. But I thought that if you did not specify a program/shell 
> that /bin/sh (in Linux I think this is usually bash) would be used. So 
> what is the difference? I see that there is a difference but what is the 
> reason?

Clay's explanation sums it up nicely.

# find the sleep process
$ ps -ef | grep sleep | grep -v grep

user  20856 20855  0 21:43 tty7     00:00:00 sleep 300

# now grep for the parent of the sleep process, PPID=20855
$ ps -ef | grep 20855

user  20855   711  0 21:43 tty7     00:00:00 -bash	# <== login shell
user  20856 20855  0 21:43 tty7     00:00:00 sleep 300	# <== note PPID

man ps(1) for more info about PID, PPID, and other info available.
 
> Clay Fandre wrote:
> > You won't see your "foo.sh" process because you are not actually
> > spawning off a new process. If all you have in your script is "sleep
> > 200" then your current shell process will run that, which will show up
> > as "bash" in your process list, not foo.sh. You need to include the
> > magic line "#!/bin/bash" in order to have it spawn off a seperate
> > child process named foo.sh.
> > 
> > 
> > On Sun, 12 Oct 2003, Rick Meyerhoff wrote:
> > 
> > 
> >>Ok, I admit my grep was a bit faulty. I find bash processes with this:
> >>$ ps -e |grep '.*as.*'
> >> 2432 pts/2    00:00:00 bash
> >> 2444 pts/4    00:00:00 bash
> >> 2467 pts/5    00:00:00 bash
> >>15087 pts/5    00:00:00 bash
> >>15366 pts/4    00:00:00 bash
> >>
> >>but substituting 'foo' for 'as' makes no difference, I still don't see 
> >>my script running. In fact if you capture all the output of ps with
> >>
> >>$ ps -e > bar
> >>
> >>and simply look at the end of the list, you see the sleep but not foo.sh.
> >>
> >>Rick Meyerhoff wrote:
> >>
> >>>I tried all those and I still don't see it. I know it does not make any 
> >>>sense. Did you guys actually try it?
> >>>
> >>>Rick Meyerhoff wrote:
> >>>
> >>>
> >>>>Try this:
> >>>>
> >>>>1. Save this one line shell script into a file called foo.sh:
> >>>>
> >>>>#
> >>>>sleep 200
> >>>>#
> >>>>
> >>>>2. $ chmod 755 foo.sh
> >>>>3. $ ./foo.sh
> >>>>4. In another terminal:
> >>>>$ ps -e | grep '*foo.sh*'
> >>>>
> >>>>Why doesn't the process show up?

_______________________________________________
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
http://www.mn-linux.org tclug-list at mn-linux.org
https://mailman.real-time.com/mailman/listinfo/tclug-list