how to call one script frm another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to call one script frm another
# 1  
Old 04-14-2008
how to call one script frm another

Hi all,

I would like to know how to call one script from another and the return the value of the called script to the calling script for further processing?(in bash)

This is kinda urgent ,pls assist

Regards
wrapster
# 2  
Old 04-14-2008
Code:
. /path/to/your/script.sh

# 3  
Old 04-14-2008
Hammer & Screwdriver Calling is easy, returning info more complicated

To call a script, simply issue the command as you would type it at the normal prompt.

Code:
#script one
echo "hello"
#call second script
good_day
#say good-bye
echo "good-bye"
exit

#script good_day
echo "good day to you"
exit 0

The above are simplified, but hopefully show you the simple logic. The last line of 'exit 0' ends the program and returns an error code of 0.
Before my '#say good-bye' line, I could check for a returned value, with somthing like:
Code:
if [ "$?" -ne 0 ]
   then
      echo "A value was returned"
fi

So, you can pass something back as part of the error-handling ability of master programs and called programs.

Otherwise, the only other effective way I know of to pass data from a called program back to the master program is to write the information to a temporary file.
# 4  
Old 06-08-2009
Hi,
I need to rin few other scripts from one main (mather) script. Working in ksh on LINUX. The only one condition - it should be run in parallel.
I mean I have to be able to call 20 scripts from this mather script in parallel (start them in the same time). Does somebody know how to do it?

Thanks,
Juliy
# 5  
Old 06-08-2009
Quote:
Originally Posted by juliyp
Hi,
I need to rin few other scripts from one main (mather) script. Working in ksh on LINUX. The only one condition - it should be run in parallel.
I mean I have to be able to call 20 scripts from this mather script in parallel (start them in the same time). Does somebody know how to do it?

Thanks,
Juliy
call each script one by one and run them in background
scr1 &
scr2 &
scr3 &
.
.
.
scr20 &
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. 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

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. Shell Programming and Scripting

shell script to copy files frm a linux machine to a windows machine using SCP

I need a shell script to copy files frm a linux machine to a windows machine using SCP. The files keeps changing day-to-day. I have to copy the latest file to the windows machine frm the linux machine. for example :In Linux, On July 20, the file name will be 20.txt and it should be copied to... (3 Replies)
Discussion started by: nithin6034
3 Replies

7. Shell Programming and Scripting

giving input to a python wch has been called frm shell script....urgent

i'm calling a python script from shell script. the python needs Y as an input everytime. how can i giv it thru shell script. I tried below code for arg in `cat erd_gen_list.lst` do generateErdSql.py -S $arg << Y done This is giving me err : `<<' unmatched pls help. (1 Reply)
Discussion started by: vini
1 Replies

8. 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

9. Programming

Reading frm text file

hi, Actually i have a text file which contain data in the following format: ---------------------------------- black pepper john barber steven johnson ------------------------------------ and the list goes on. I'm writing a c program that reads the text file and output the following... (10 Replies)
Discussion started by: kanexxx
10 Replies
Login or Register to Ask a Question