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 03-29-2012, 03:18 AM   #1
avataratar
LQ Newbie
 
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
Post Shell Script to start a program either not running or kill if running


Hi Gurus,
I have alredy checked the forum but did not find exact match to my requirements.
I am looking for assistance in creating a script that does the following:
1. I need to pass the 2 arguments, one is user, other one system identifier.
2. if the 2nd letter of user contain "e" (not case sensitive), then proceed further. Otherwise exit.
3. If 2nd letter "e" match, then find the pid of program for that user because same server might running same program on 2 different user.
4. kill the program of the pid
5. check if completely killed the program of that user.
6. start the program for that user by doing the following command
setenv JAVA_HOME /usr/sap/<2nd argument>/java/jdk1.6.0_23
setenv PATH ${JAVA_HOME}/bin:${PATH}
either cd /usr/sap/<2nd argument>/SIC or SIC6.0/bin & ./run.sh &
or
/usr/sap/<2nd argument>/SIC or SIC6.0/bin/run.sh &
Thank you very much. All help appreciated.
 
Old 03-29-2012, 03:45 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello and welcome to LinuxQuestions,

This sounds pretty much like homework to me. If it is then you should know that we will not do the work for you. Check the LQ Rules to which you agreed when signing up:
Quote:
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
Even if it's not homework, you cannot expect us, who are all volunteers here, to do all the work for you. It all bottles down to:
Show us what you've got and where it's failing and we'll be glad to help.

Some good starting points:
Bash Guide for Beginners
Advanced Bash Scripting Guide

Looking forward to your participation in the forums. Have fun with Linux.

Kind regards,

Eric
 
1 members found this post helpful.
  


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
Shell script to start another program, if not running. cooljai Linux - Software 13 03-13-2012 05:39 AM
Shell script to start program if not running 3lixy Linux - Software 4 08-07-2011 04:22 PM
running a C program from shell script jkeertir Linux - Newbie 3 05-19-2008 06:05 AM
shell script to kill processes running on port number varunbihani Linux - Newbie 13 12-06-2005 09:46 AM
Running shell script within a C or C++ program Quantum0726 Programming 2 06-15-2005 10:14 PM


All times are GMT -5. The time now is 04:52 AM.

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