Expect or sftp question ?

From: newexpectuser (anthonypieper_at_cs.com)
Date: 10/28/03


Date: 28 Oct 2003 05:29:55 -0800

I'm not sure if this falls into an Expect or sftp question, but I am
trying to get some files into the /client/files/in directory.

This script is called from another script. When the line lpwd runs, it
does give me "client/files/in", but my files don't get transfered into
this directory. I've tried to add a sleep command just in case it was
running too fast. It seems the lcd command is not working properly.

#!/usr/bin/expect -f
spawn sftp root@xxx.xxx.xx.xxx
set timeout 180
set FAILED 2
set CDFAILED 3
expect {
    timeout {
        exit $FAILED
    }
    "password:" {
       send "xxx\r"
    }
}
expect "sftp>"
send "cd /customer/mailbox/inbox\r"
expect "sftp>"
send "lcd /client/files/in\r"
sleep 30
expect {
    "Couldn't canonicalise: No such file or directory" {
        exit $CDFAILED
    }
    "sftp>" {
        send "lpwd\r"
        send "mget *.dat\r"
    }
}
expect "sftp>"
send "quit\r"



Relevant Pages

  • [HPADM] [SUMMARY] RE: SFTP Scripting
    ... We are trying to set up an SFTP environment with a partner. ... need to now is to script it so it is non-interactive. ... Echo "Ending of test sftp script ... ...
    (HP-UX-Admin)
  • Re: Ssh and sftp via here document
    ... The file transfer is performed by sftp during an ssh ... session in which the user running the script temporarily becomes ... can be done without storing cleartext passwords in the script. ...
    (comp.security.ssh)
  • Re: sftp exit codes?
    ... I am using scp along with BatchMode on command line. ... better choice over sftp. ... of exit codes for the sftp program and what each one ... I'm actually porting a shell script that use to use ...
    (SSH)
  • Re: sftp script for application promotion
    ... execute the transfers. ... You don't have such things as sftp scrips. ... You can create a shell script ... You can create batch files with sftp though, ...
    (comp.sys.sun.admin)
  • Re: which is better libssh or libssh2
    ... And how is sftp more secure than scp or rsync over ssh? ... As I said AFAIK libssh2 impliments the ssh2 protocol which is more secure ... transmission timing will swamp any script issues. ...
    (comp.security.ssh)