LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 15
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
 
Old 07-27-2003, 02:30 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Linux Mint 18
Posts: 7,809

Rep: Reputation: 294Reputation: 294Reputation: 294
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 03:09 PM.
 
  


Reply


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 02:52 PM
Starting programs as root jrdioko Linux - Software 2 03-17-2005 12:26 AM
Programs not starting Floydian Linux - Newbie 8 12-28-2004 12:04 PM
starting programs on startup -how? br0k3n Linux - General 3 07-22-2004 05:43 PM
Programs Not Starting BrandonJG Linux - General 2 09-02-2002 09:52 AM


All times are GMT -5. The time now is 02:06 PM.

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