Re: Novice needs help using Expect to automate sftp
- From: rsine <rsine@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 13 Jul 2007 10:50:30 -0700
On Jul 13, 1:17 pm, rsine <rs...@xxxxxxxxxxxxxxxxxxx> wrote:
On Jul 13, 1:04 pm, Bill Marcum <marcumb...@xxxxxxxxxxxxx> wrote:
On Fri, 13 Jul 2007 08:03:19 -0700, rsine <rs...@xxxxxxxxxxxxxxxxxxx> wrote:
I have been struggling with a project that requires me to use sftp.
After working through all the issues getting sftp working on AIX 5.3,
I now need to automate the sftp process. This appears harder than it
should be. It appears that getting past the password prompt is a
frustration everyone runs up against. After much reading, I thought
Expect was the key and I installed it. Unfortunately, it does not
seem to be working. Here is what I am trying:
# /usr/bin/expect << EOF
spawn sftp usern...@xxxxxxxxxxxxx
expect "password:"
send "my_password"
send "my_password\r"
--
Police are unsure if the same wookie is involved in Sunday's assault.
Bill,
I think my issue is with the password. The vendor created one with "$
$" in it ala AbCDE$$123. I know the "$" symbol has a special meaning
for Unix. How can I pass the "$$" in a password? Enclosing the
password in quotes did not help.- Hide quoted text -
- Show quoted text -
Thanks for all the help. After more research, I discovered
autoexpect. Using this tool, I was able to capture all that I was
executing. Looking at the autoexpect file, I found the password
needed the dollar signs entered as "\$\$" and the "\r" needed to be
concatenated to the data (I was leaving a space between).
For all those novices like me, here is what I found to work:
expect << EOF
spawn sftp username@xxxxxxxxxxxxx
expect "password:"
send -- "my_pa\$\$word\r"
expect "sftp> "
send -- "ls\r"
expect "sftp> "
send -- "exit\r"
EOF
.
- References:
- Novice needs help using Expect to automate sftp
- From: rsine
- Re: Novice needs help using Expect to automate sftp
- From: Bill Marcum
- Re: Novice needs help using Expect to automate sftp
- From: rsine
- Novice needs help using Expect to automate sftp
- Prev by Date: Re: Novice needs help using Expect to automate sftp
- Next by Date: File Move Different In scripting
- Previous by thread: Re: Novice needs help using Expect to automate sftp
- Next by thread: File Move Different In scripting
- Index(es):