[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ftp inside shell script  is not working as expected

Posted on 2006-05-09
5
Medium Priority
?
1,040 Views
Last Modified: 2013-12-27
My Script looks as follows :::



#!/bin/ksh


echo "ENV = $ENV"

if [ "$ENV" = "devl" ]
then
      EPT_SERVER_NAME=mybox01
      EPT_USER=mylogin
      EPT_PASSWORD=mypassword
      BBERG_SERVER_NAME=mybox09
      BBERG_USER=mypasswd
      BBERG_PASSWORD=mypassword
elif [ "$ENV" = "test" ]
then
      EPT_SERVER_NAME=mybox01
      EPT_USER=mylogin
      EPT_PASSWORD=mypassword
elif [ "$ENV" = "acpt" ]
then
      EPT_SERVER_NAME=mybox01
      EPT_USER=mylogin
#      EPT_PASSWORD=mypassword
elif [ "$ENV" = "prod" ]
then
      EPT_SERVER_NAME=mybox01
      EPT_USER=mylogin
#      EPT_PASSWORD=mypassword
      BBERG_SERVER_NAME=mybox09
      BBERG_USER=mylogin
      BBERG_PASSWORD=mypassword
fi


 # Copying the dat file to Pool Talk server
     ftp -n $EPT_SERVER_NAME <<!
     quote user $EPT_USER
     quote pass $EPT_PASSWORD
     binary
     cd /appl/ept$ENV/data/in/mbs
     lcd /appl/l7$ENV/data/out/2006
     put SchA.dat
     quit
     !
 # Copying the dat file to BloomBerg server
     ftp -n $BBERG_SERVER_NAME <<!
     quote user $BBERG_USER
     quote pass $BBERG_PASSWORD
     binary
     cd /export/appl/website/RTMDS/ftp/bberg/mfdisclose/input/
     lcd /appl/l7$ENV/data/out/2006
     put MF_SCHEDA_*.dat
     quit
     !



Now My Question is :
          As you can see  from my script that i am trying ftp the file to two different remote servers. It connects to the first server (EPT SERVER), and copies the file to the specified location but when it enters the quit command, instead of exiting from the ftp session and going to the next ftp  session , it exits from shell script.

After quit command the control is not coming back to the shell script, instead it exits from shell script itself.

Thanks
Subha
0
Comment
Question by:SubhaBabu
  • 3
5 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 16644620
First replace the IF statement with a "case" statement may it more readable.


replace "!" with EOF and make sure there is no WHITE space before EOF, eg:

    ftp -n $BBERG_SERVER_NAME <<EOF
     quote user $BBERG_USER
     quote pass $BBERG_PASSWORD
     binary
     cd /export/appl/website/RTMDS/ftp/bberg/mfdisclose/input/
     lcd /appl/l7$ENV/data/out/2006
     put MF_SCHEDA_*.dat
     quit
 EOF


add "set -x" as the 2nd line of your script to help you to debug the script.

PS: if you want more reponse from the experts, consider increase the point value for the question.
0
 
LVL 21

Expert Comment

by:tfewster
ID: 16645798
yuzh - As Page Editor, can you remove all the server names/user ids/passwords before SubhaBabu gets fired for posting them on the Internet?!
0
 
LVL 38

Expert Comment

by:yuzh
ID: 16646253
Good suggestion tfewster,thank you.

    yuzh
0
 
LVL 2

Author Comment

by:SubhaBabu
ID: 16657857
yuzh,
      EOF did not work for me. I just removed quit and had ! and it worked, now my script looks as below

ftp -n $BBERG_SERVER_NAME <<EOF
     quote user $BBERG_USER
     quote pass $BBERG_PASSWORD
     binary
     cd /export/appl/website/RTMDS/ftp/bberg/mfdisclose/input/
     lcd /appl/l7$ENV/data/out/2006
     put MF_SCHEDA_*.dat
    !

 # Copying the dat file to Pool Talk server
     ftp -n $EPT_SERVER_NAME <<!
     quote user $EPT_USER
     quote pass $EPT_PASSWORD
     binary
     cd /appl/ept$ENV/data/in/mbs
     lcd /appl/l7$ENV/data/out/2006
     put SchA.dat
     !


Thanks
0
 
LVL 38

Accepted Solution

by:
yuzh earned 150 total points
ID: 16664050
There is nothing wrong with using EOF or !,  "quit" also works.

see my script in http:Q_21009907.html#11209872

also http:Q_20702441.html

You need to make sure there is no WHITE SPACE before EOF or ! (at the end of ftp actions).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question