Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-27-2003, 03:18 PM   #1
Registered: Jun 2003
Location: Ottawa
Distribution: Enterprise 3
Posts: 37

Rep: Reputation: 15
starting programs in .bashrc


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

Old 07-27-2003, 03:30 PM   #2
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,313

Rep: Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538
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.

Last edited by jailbait; 07-27-2003 at 04:09 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting programs charnel Linux - General 1 08-02-2005 03:52 PM
Starting programs as root jrdioko Linux - Software 2 03-17-2005 01:26 AM
Programs not starting Floydian Linux - Newbie 8 12-28-2004 01:04 PM
starting programs on startup -how? br0k3n Linux - General 3 07-22-2004 06:43 PM
Programs Not Starting BrandonJG Linux - General 2 09-02-2002 10:52 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:18 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration