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

#!/usr/bin/ksh
PROVDIR=/apps/dev/provimage/scripts
# FTP to provimage
echo "Connecting to Provimage...."
ftp -inv bsbar01s.bcbsma.com << EOF_FTP
user xyz pwd
cd $PROVDIR
exec extract_ancillary.bat
bye
EOF_FTP

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

Please help me out.
Regards,
Vineeta

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.

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 you.it 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.

Regards,
Vineeta

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

Hi,

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

ssh user@bsbar01s.abc.com"/apps/dev/provimage/scripts/extract_ancillary.bat"
Password:
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.

Thanks,
Vineeta

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 user@bsbar01s.abc.com". .profile; /apps/dev/provimage/scripts/extract_ancillary.bat"