LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Need simple bash script help (https://www.linuxquestions.org/questions/linux-general-1/need-simple-bash-script-help-497438/)

rickenbacherus 11-01-2006 12:36 AM

Need simple bash script help
 
I need ivman to run once as user 'ivman' on boot (no problem) and once as $USER on login so a test is required for an already running ivman as $USER. In case you log out and then back in we do not want 2 instances of ivman running as $USER

I'm getting closer but still no workie. Any help would be great. Ultimately the script would test for $CURRENTLY_LOGGED_IN_USER but it's not critical. I can figure that out later. Thanks.

Code:

#!/bin/sh

IVMAN=`which ivman`
id=`pgrep -U glenn ivman`

if [ '$id' -eq '0' ]

then
  $IVMAN
 else
 exit
fi


cdhgee 11-01-2006 02:44 AM

How about something like the following instead of your pgrep line:

Code:

ps -ef | grep ivman | grep $USER | cut -f3
Adjusting -f3 to the appropriate field where necessary (I can't remember the PID field number off the top of my head).


All times are GMT -5. The time now is 02:28 AM.