Thread: testing correct execution of commands inside a script that executes ftp

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    1

    testing correct execution of commands inside a script that executes ftp

    I have a script like this:

    sync
    SRC=/home/_My/Target/etc
    HOST='10.x.y.z
    USER='user'
    PASSWD='passwd'



    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    verbose
    bell
    binary


    cd /fw/user

    lcd $SRC
    put file.xml
    put web.xml

    lcd $SRC/targetScripts
    prompt
    mput *
    prompt



    quit
    END_SCRIPT

    if test $? -eq 0
    then echo OK
    else echo ERROR!! error code = $?
    fi

    echo install completed

    exit 0
    It executes correctly but the question is:

    after a shell command inside the script i can test its correct execution by testing $?
    but how to do it after each single command i give to ftp??

    Please help me!!
    I tested the fact that if a single ftp command fails $? at the end doesn't tell it (it is 0)

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You can't. The shell sleeps until ftp ends.

    One option is to use 'expect' to write an interaction script with the ftp program.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Executing DOS commands from inside an image
    By Moony in forum C Programming
    Replies: 6
    Last Post: 03-16-2008, 12:40 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM