ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

sFTP using EXPECT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • sFTP using EXPECT

    I am using EXPECT to send data to a partner that requires userid/password authentication. Here is my script:

    #!/usr/local/bin/expect -f
    log_file -noappend /ford/log.log
    spawn sftp aidistributors@xxxxxxxxx.com
    expect {
    default {exit 10}
    "password:"
    }
    send "********"
    expect {
    default {exit 20}
    "sftp> "
    }
    send "lcd /ford\n"
    expect {
    default {exit 30}
    "sftp> "
    }
    send "mput FORD*.TXT\n"
    sleep 60
    expect {
    default {exit 40}
    "sftp> "
    }
    send "quit\n"
    exit 0


    This works most of the time. But occasionally the only thing in my log is the initial command "spawn sftp aidistributors@dstftp2.dstinc.com", the script ends and the message "QShell command failed with status 0000000010 and signal 0000000000 " is sent.

    I have spoken with my partner and am told there is no record in their logs that a connection attempt was made. Is there a way I can determine what, if anything, was received from my attempt to make the connection?

    Thanks in advance.

  • #2
    This is from your code:

    Code:
    spawn sftp [EMAIL="aidistributors@dstftp2.dstinc.com"]aidistributors@xxxxxxxxx.com[/EMAIL]
    expect {
    default {exit 10}
    "password:"
    }
    So it is launching the sftp command, and if it doesn't receive 'password:' it will return exit status 10. You told us the script is ending with 'QShell command failed with status 0000000010' so we know it is getting exit status 10, so that is what is happening.

    If I had to guess, the network connection is down for some reason, or there's some hiccup on the internet that's causing the connection to fail. Eventually, it times out and returns exit status 10. So, just re-try.

    Comment

    Working...
    X