Depend on Script message needs to be invoke anothe script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Depend on Script message needs to be invoke anothe script
# 1  
Old 09-23-2014
RedHat Depend on Script message needs to be invoke anothe script

I have script below
Code:
 
 #! /bin/bash
 if [ -z "$(ps -ef | grep java | grep jboss)" ]
then
        echo "JBoss is NOT running"
 else
        echo "JBoss is running"
fi

If JBoss is NOT running need to be invoke another script i.e jboss startup script /home/vizion/Desktop/jboss-4.2.3.GA/bin/run.sh script from other script not include above script


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by rbatte1; 09-23-2014 at 07:28 AM.. Reason: Added ICODE tags for the required script to be called.
# 2  
Old 09-23-2014
Can you elaborate on what you require...I couldn't understand your requirement clearly
# 3  
Old 09-23-2014
Hi,

You have answered this yourself, I think.

Code:
#! /bin/bash
if [ -z "$(ps -ef | grep java | grep jboss)" ]
then
echo "JBoss is not running"
/home/vizion/Desktop/jboss-4.2.3.GA/bin/run.sh
else
echo "JBoss is running"
fi

If you wanted you could test for success after the "run.sh" but I would expect that script to log it's own errors and exit status.


Regards

Dave

Last edited by gull04; 09-23-2014 at 05:30 AM.. Reason: Code Tags
# 4  
Old 09-23-2014
If the script posting message "JBoss is not running ". Depends that message we need to invoke another script below
Code:
 
 #! /bin/bash
  
 /home/vision/Desktop/Jboss/bin/run.sh

Needs to separate both the script but when jboss is not running needs to be invoke startup script

Thanks
-cg


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks
# 5  
Old 09-23-2014
Hi,

I've edited the original code.

Regards

Dave
# 6  
Old 09-23-2014
You still did answer yourself,partly at least Smilie

Example name: isRunningJ.sh
Code:
#! /bin/bash
if [ -z "$(ps -ef | grep java | grep jboss)" ]
then
    echo "JBoss is not running"
    exit 1
else
    echo "JBoss is running"
    exit 0
fi

One liner...
Code:
isRunningJ.sh || /home/vizion/Desktop/jboss-4.2.3.GA/bin/run.sh

Regular:
Code:
if ! isRunningJ.sh
then   /home/vizion/Desktop/jboss-4.2.3.GA/bin/run.sh
fi

Hope this helps

Last edited by sea; 09-23-2014 at 06:05 AM.. Reason: typo: return != exit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script of invoke an email program

Is it possible that a shell script invokes a windows mailing application like Lotus Notes and creates a mail and sends it ? (2 Replies)
Discussion started by: csrohit
2 Replies

2. Emergency UNIX and Linux Support

invoke one script based on previous script execution

I am database guy and not very good at shell scripts. I am seeking help to sharp my script coding. I have 5 scripts 1. master script. I use this one to call other four scripts to do database work. 2. db_backup_1 and log_backup_1 3. db_backup_2 and log_backup_2 in master script, I want to... (4 Replies)
Discussion started by: duke0001
4 Replies

3. Shell Programming and Scripting

Not able to invoke a sh script from KSH

Hi all, Iam writing a KSH script which needs to export dispaly to Xwindows and then involke a sh script .. But a core file is getting genrated for reasons not known to me. Please check i need incorporate below mentioend code in my script which iam not abel to .. export DISPLAY=`who am i |... (1 Reply)
Discussion started by: rahman_riyaz
1 Replies

4. Shell Programming and Scripting

need to invoke a script upon arrival of a file

hi all, i recieve a file from other server, on a daily basis .... but the time of arrival is unpredictable .... i need to move this file to another directory before the next file arrives ... i have written a script that does this op and performs some manipulations on the data... but i... (2 Replies)
Discussion started by: sais
2 Replies

5. Solaris

To invoke a script on a remote machine

Hi, I am trying the following- 1. ftp a file from machine1 to machine2. 2. Once the ftp is done, from machine1 invoke a shell script on machine2. Could anyone please help me on this? (5 Replies)
Discussion started by: sam_roy
5 Replies

6. Shell Programming and Scripting

Invoke shell script in cgi script

Hi, I just tried to call a simple shell script from a cgi script writing in c programming.But,it is not working.i will be grateful if anyone can show me the problems going on as i m new to c and oso shell script.Thanks. -Here is my shell script of call the 'pc shut down' system command in... (1 Reply)
Discussion started by: carolline
1 Replies

7. Shell Programming and Scripting

how to Invoke html in ksh Script

how to invoke html file from a ksh shell plz help......... (4 Replies)
Discussion started by: ali560045
4 Replies

8. Shell Programming and Scripting

invoke same script twice

hey, can I invoke the same script twice simultaneously? I want both instances to run at the same time with different parameters. Thanks! (2 Replies)
Discussion started by: mpang_
2 Replies

9. Shell Programming and Scripting

Invoke java program in script

Hey all, My boss tasked me with the job to write a script which would invoke various java programs, the thing is I don't know much about shell scripting so would you experts help me out? Here is the requirement - 2 applications written in java: App_A and App_B -... (0 Replies)
Discussion started by: mpang_
0 Replies

10. Shell Programming and Scripting

how to invoke shell script

hi everybody, i learning unix now only.Can u pls guide me in invoking a shell script.Actually i need to know how to write the command for invoking the shell script.Suppose the shell file name is count , then how i will write the command. thanks (1 Reply)
Discussion started by: gopa_mani
1 Replies
Login or Register to Ask a Question