Correct shell script to Call One shell script from another shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Correct shell script to Call One shell script from another shell script
# 1  
Old 12-07-2012
Correct shell script to Call One shell script from another shell script

Hi All,

I have new for shell scripting.

Problem : I have one scrip at serv1 and path of server is /apps/dev/provimage/scripts and script name:extract_ancillary.bat.

I need to call this script at server2(my working server) and execute at server2 .

Please let me know how to build the script for this.

I build one scripts on the server2 but its not running .Please let me know where I am wrong and please correct my script.

Script: abc.ksh
# FTP to provimage
echo "Connecting to Provimage...."
ftp -inv << EOF_FTP
user xyz pwd
exec extract_ancillary.bat

Please let me know the correct coding for this requirement.Its very urgent .

Please help me out.
Moderator's Comments:
Mod Comment Code tags please, please do not use bold fonts, we need to read your posts an understand them

Last edited by jim mcnamara; 12-07-2012 at 12:39 PM..
# 2  
Old 12-07-2012
There is no way to "exec" a file in ftp.

You will have to use commands like rsh or ssh to run a script on a remote box.
# 3  
Old 12-07-2012
Please let me know how to complete my requirement

Hi ,

I am trying to get the script "extract_ancillary.bat" from server 1 to server2 (my unix box) through FTP command and then try to execute the script at server 2 by passing the command as recommneded by showing me below error.

Ist Commnad screen shot :
bsedas03s> ssh extract_ancillary.bat
ssh: extract_ancillary.bat: node name or service name not known

2nd command screen shot;
bsedas03s> sh extract_ancillary.bat
extract_ancillary.bat: APPMODE=dev: is not an identifier

Please let me know how to implement the requirement.

Please reply me asap as it is very urgent for deliverables.


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

Last edited by Franklin52; 12-07-2012 at 02:35 PM..
# 4  
Old 12-07-2012
If you want to use ssh to run a remote script, then follow below syntax:-
ssh username@hostname "absolute path of your script"

ssh username@hostname "/home/vineeta/extract_ancillary.bat"

Note: Replace highlighted path with the absolute path of your script: extract_ancillary.bat
# 5  
Old 12-07-2012
Again getting error: please help me to find solution


I ran the script as per your comment but got the error:
Error :DEV

The APPMODE dev is not same as what you are running at.

This script is running successfully on the server where it is placed but didn't running to my server.

Please provide me some for the above issue or let me know the another solution.

Please do me reply.


Last edited by Scott; 12-15-2012 at 06:13 AM.. Reason: Code tags
# 6  
Old 12-07-2012
First of all, please use code tags when posting code fragments or data samples in your post. If you are not sure how to do it, please refer this thread

Since I don't know anything about your script, I cannot provide the root cause of this failure, but I suggest you to source your .profile file and give it another try:-
ssh". .profile; /apps/dev/provimage/scripts/extract_ancillary.bat"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 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

Call a function in shell script from another shell script

I've 2 shell scripts viz., CmnFuncs.ksh and myScript.ksh. 1st script contains all common functions and its code is as below: $vi CmnFuncs.ksh #!/bin/ksh RunDate() { .... .... export Rundt=`date +%Y%m%d` } 2nd script is invoking the above one and I expect to use the RunDt variable... (8 Replies)
Discussion started by: njny
8 Replies

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

4. Shell Programming and Scripting

Call shell script function from awk script

hi everyone i am trying to do this bash> cat deepak() { echo Deepak } deepak bash>./ Deepak so it is giving me write simply i created a func and it worked now i modified it like this way bash> cat (2 Replies)
Discussion started by: aishsimplesweet
2 Replies

5. Red Hat

how to call a particular function from one shell another shell script

please help me in this script shell script :1 *********** >cat #!/bin/bash echo "this is first file" function var() { a=10 b=11 } function var_1() { c=12 d=13 (2 Replies)
Discussion started by: ponmuthu
2 Replies

6. Shell Programming and Scripting

call another shell script and pass parameters to that shell script

Hi, I basically have 2 shell scripts. One is a shell script will get the variable value from the user. The variable is nothing but the IP of the remote system. Another shell script is a script that does the job of connecting to the remote system using ssh. This uses a expect utility in turn. ... (2 Replies)
Discussion started by: sunrexstar
2 Replies

7. Shell Programming and Scripting

shell script to call perl script problems

Ok, don't ask me why, but all calls to perl must be called by a shell script. Its really not ideal, but its what I have to work with. Calling it isnt the issue, its passing in the arguments. I have about 1000 perl scripts to call by a shell script. Right now, I'm executing the shell script... (3 Replies)
Discussion started by: regexnub
3 Replies

8. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./ $t $d $m'); in shell scipt 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. UNIX for Dummies Questions & Answers

To call/execute a shell script from a shell script

Hi , I have 4 shell scripts a.ksh b.ksh -> depends on a.ksh success -> log into b.log c.ksh -> depends on b.ksh success -> log into c.log d.ksh -> depends on c.ksh success -> log into d.log I will have to write main.ksh ( execute a.ksh , log into a.log if a.ksh= success, execute... (1 Reply)
Discussion started by: konark
1 Replies

10. Shell Programming and Scripting

Have a shell script call another shell script and exit

I have a shell script that calls another shell script "str_process_main" that runs in a loop until a given time. I want the first script to just call the second one and then exit. The first script is: #!/bin/ksh DATE=$(date +%m%d%y) DPID=$(ps -ef|grep str_process_main|grep -v grep) if ;... (2 Replies)
Discussion started by: heprox
2 Replies
Login or Register to Ask a Question

Featured Tech Videos