call script inside one script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting call script inside one script
# 1  
Old 09-02-2011
call script inside one script

Hi,

Requirement:-

I have 3 scripts(say A.sh,B.sh & C.sh).Now am executing these 3 scripts seperately.requirement is to run these 3 scripts as single from one main script,this script has to call A.sh and if A.sh executed completely,it has to invoke B.sh and like the 3 rd one.And while executing the 2nd script its asking one prompt
(eg:-Do you really want to rename(enter YES or NO)? ),there "YES" has to enter...how will this implement.please help...
# 2  
Old 09-02-2011
Just put the scripts in the main script like you run from the command prompt.
All would be executed serially.

Code:
#! /usr/bin/ksh

/path/to/A.sh
/path/to/B.sh
/path/to/C.sh

About the prompt, Its not clear where you want to prompt? Is it inside script B.sh or in main script?

Where-ever it is, that should be something like below

Code:
echo -n "Do you really want to rename - YES/NO?"
read answer

if [ "$answer" = "YES" ]; then
 # steps
fi

# 3  
Old 09-02-2011
Quote:
Originally Posted by Sanal
Hi,

Requirement:-

I have 3 scripts(say A.sh,B.sh & C.sh).Now am executing these 3 scripts seperately.requirement is to run these 3 scripts as single from one main script,this script has to call A.sh and if A.sh executed completely,it has to invoke B.sh and like the 3 rd one.And while executing the 2nd script its asking one prompt
(eg:-Do you really want to rename(enter YES or NO)? ),there "YES" has to enter...how will this implement.please help...
I needed in past something like.... but:
Write script_1.sh and then inside it :

Xterm -e " . /script_2 ; killall xterm ; "
Xterm -e " . /script_3 ; killall xterm ; "
Xterm -e " . /script_4 ; killall xterm ; "
....

I hope this helps.
# 4  
Old 09-02-2011
Code:
if [ "$answer" = "YES" ]; then 
 # steps 
fi

I would be more inclined to reverse the condition to:

Code:
if [  "$answer"  !=  "YES"  ]; then 
 exit 1
fi

While both work, I find that matching "if",s and "fi", that extend over a page or so of code to be error prone.
This User Gave Thanks to jgt For This Post:
# 5  
Old 09-02-2011
Try this

Hi Sanal

You can try this also..
Call first script in mail script (A.sh)

put B.sh in last line of A.sh , and likewise C.sh

If A.sh ran it will call B.sh and likewise...

Main Script
A.sh
B.sh
C.sh

hope it helps
Atul
# 6  
Old 09-04-2011
thanks all for helping.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

2. UNIX for Dummies Questions & Answers

Call a UNIX script inside another and dont wait for it

Hi I have two scripts script1.sh and script2.sh(say this script is a long running). I want to call script2.sh inside and script1.sh,but when i call script2.sh i dont want to wait for script2 to complete and want this to run in back ground and go on next commands in script 1.sh and finally at the... (2 Replies)
Discussion started by: lijjumathew
2 Replies

3. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

4. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

5. Shell Programming and Scripting

Script to call a menu script and redirect each option to a text file

Hello, I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file. For example;- In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies

6. UNIX for Advanced & Expert Users

Using PHP , call a sql inside a unix script

I am running the xampp on WINDOWS, and my php script is connecting to a unix script on a different server (ssh2_connect("11.31.138.56", 22). I am running the unix script and inside this script I am calling the .sql file . The SQL is connecting to oracle db on the unix server. But the sqlplus... (2 Replies)
Discussion started by: madfox
2 Replies

7. Shell Programming and Scripting

How to call an sql script inside a while statement in KSH

Hi all, I'm trying to run an sql inside a loop which looks like this #!bin/ksh while IFS=, read var1 var2 do sqlplus -s ${USERNAME}/${PASSWORD}@${ORACLE_SID} << EOF insert into ${TABLE} ( appt_date ) values ( '${var1 }' ); ... (6 Replies)
Discussion started by: ryukishin_17
6 Replies

8. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

9. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

10. Shell Programming and Scripting

Call a perl script inside a shell script

Hi all, I have the following snippet of code.. #!/bin/sh echo "run perl script............" #Run the verification script perl bill_ver echo " perl script completed....." echo "rename files......" #Remove from all file in the directories test, test1, test2, test3 for f in... (3 Replies)
Discussion started by: chriss_58
3 Replies
Login or Register to Ask a Question