> Thank you, I tried that and here's what I get:
> if the process is running I get "proc23.sh: test: ] missing" error.
> if it's not running: "proc23.sh: test: argument expected" error.
> Here's my script:
> #!/bin/sh
> PROC_EXISTS=`ps -ef | awk '/DAS/ && !/awk/ {print $2}'`
> if [ -n "$PROC_EXISTS"]; then
> echo "Yahoooo... mgr is still alive!"
> else
> echo "Shit... mgr is dead!"
> fi
> > >Hi, I'm new at this and I need help. I'm trying to write a little
> > >script that will check for a particular process and let me know if it's
> > >running or not.
> > >I use the following line to identify the process id by name:
> > >ps -ef | awk '/DAS/ && \!/awk/ {print $2}'
> > >I can run this at commandline just fine, but when I try to assign the
> > >result of this to a variable I have a problem:
> > >/awk/: Event not found.
> > Are you sure you didn't forget the '\' before '!'?
> > >Can someone suggest what am I doing wrong? I played around with different
> > >quote marks and escape characters and didn't achieve anything.
> > >Thank you for all your help.
> > >Alex.
> > >Below is the script I'm working on:
> > >----------------------------------------
> > >!#sh
> > That should be "#!/bin/sh".
> > >PROC_EXISTS=`ps -ef | awk '/DAS/ && \!/awk/ {print $2}'`
> > You don't need to escape the ! in Bourne shell, only in C shell.
> > >if [ $PROC_EXISTS -gt 0 ]; then
> > If no process was found, $PROC_EXISTS will be empty, so the above line will
> > become:
> > if [ -gt 0 ]; then
> > which makes no sense. Try:
> > if [ -n "$PROC_EXISTS" ]; then
> > > echo "still alive!"
> > >else
> > > echo "it is dead..."
> > >fi
> > >----------------------------------------
> > --
> > Genuity, Woburn, MA
> > *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> > Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.