LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   starting programs in .bashrc (https://www.linuxquestions.org/questions/linux-newbie-8/starting-programs-in-bashrc-76402/)

bluemoose 07-27-2003 02:18 PM

starting programs in .bashrc
 
Hi,

whats a good way to start a program in the .bashrc file for a particular user only on the condition that the program hasn't already been started by someone else.

I can get 'ps -A | grep prog_name' to tell me if the program is running but I can't figure out the syntax to put this in an if statement in my .bashrc file

bluemoose

jailbait 07-27-2003 02:30 PM

The exit status of ps is stored in $?. Make the following statement an if statement to check $? for the grep exit status. My guess is that a zero exit status means that prog_name is running and a non zero exit status means that prog_name is not running, but you may have to figure that out by trial and error.


All times are GMT -5. The time now is 01:57 AM.