Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    4

    Unanswered: FTP script problem

    FTP script problem
    I'm new unix enviroment, and I have mamnaged to wrote a script to ftp a file from a remote machine.
    My problem when the ftp has executed all other lines in the script are ignored and script exits. The message "file transfer has completed" is not displayed and date . Below is my sample script.

    Please tell me what I am doing wrong here.

    #!/bin/ksh
    userString="brsgadmin"
    pswdString="brsg6906"
    #ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
    ifmsfile="COPY_DB_STATUS.DAT"
    ftp -in ba0470.optus.com.au <<-END_FTP
    user $userString $pswdString
    get ${ifmsfile}
    quit
    -END_FTP

    echo "file transfer has completed"
    date

  2. #2
    Join Date
    Jan 2004
    Posts
    1
    well you could try to put the last two lines:the one with the message and the one with the date before quit

  3. #3
    Join Date
    Aug 2003
    Location
    Massachusetts, USA
    Posts
    106

    Re: FTP script problem

    I would suggest breaking the FTP portion into another ksh file you call from this one. That way you can truly tell whether the transfer completed successfully. Your script as it is assume the transfer will work all the time successfully. Example:

    echo "**** Transfering file ****"
    ksh push.ftp > /tmp/push_ftp.$$
    if (grep -c "Transfer complete" /tmp/dnb_ftp.$$ > /dev/null);
    then
    echo "**** Transfer Complete ***"
    else
    echo "**** Transfer ERROR ****"
    fi

    Originally posted by adokli
    FTP script problem
    I'm new unix enviroment, and I have mamnaged to wrote a script to ftp a file from a remote machine.
    My problem when the ftp has executed all other lines in the script are ignored and script exits. The message "file transfer has completed" is not displayed and date . Below is my sample script.

    Please tell me what I am doing wrong here.

    #!/bin/ksh
    userString="brsgadmin"
    pswdString="brsg6906"
    #ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
    ifmsfile="COPY_DB_STATUS.DAT"
    ftp -in ba0470.optus.com.au <<-END_FTP
    user $userString $pswdString
    get ${ifmsfile}
    quit
    -END_FTP

    echo "file transfer has completed"
    date

  4. #4
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138
    If you create a file named .netrc in your $HOME directory with the permissions 400 you dont need USER and PASS for ftp.
    This is only a tip for using ftp.
    Greetings from germany
    Peter F.

  5. #5
    Join Date
    Feb 2004
    Posts
    1

    Re: FTP script problem

    For anyone else who reads this thread, the proper script should be:

    #!/bin/ksh
    userString="brsgadmin"
    pswdString="brsg6906"
    #ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
    ifmsfile="COPY_DB_STATUS.DAT"
    ftp -in ba0470.optus.com.au <<-END_FTP
    user $userString $pswdString
    get ${ifmsfile}
    quit
    END_FTP

    echo "file transfer has completed"
    date

    where "-END_FTP" at the end is changed to "END_FTP" (without the "-" character)

    Originally posted by adokli
    FTP script problem
    I'm new unix enviroment, and I have mamnaged to wrote a script to ftp a file from a remote machine.
    My problem when the ftp has executed all other lines in the script are ignored and script exits. The message "file transfer has completed" is not displayed and date . Below is my sample script.

    Please tell me what I am doing wrong here.

    #!/bin/ksh
    userString="brsgadmin"
    pswdString="brsg6906"
    #ifmsdir="NSPPRO_USR1:[USERS.IFMS.BRSGADMIN]"
    ifmsfile="COPY_DB_STATUS.DAT"
    ftp -in ba0470.optus.com.au <<-END_FTP
    user $userString $pswdString
    get ${ifmsfile}
    quit
    -END_FTP

    echo "file transfer has completed"
    date

  6. #6
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    The - betwen << and label END_FTP indicates that datas until END_FTP can be prefixed by a TAB that will be ignored.
    The code can be rewritten like this :

    Code:
    ftp -in ba0470.optus.com.au <<-END_FTP
            user $userString $pswdString
            get ${ifmsfile}
            quit
            END_FTP
    Jean-Pierre.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •