Re: scp failing
- From: hendedav@xxxxxxxxx
- Date: Wed, 8 Apr 2009 07:34:57 -0700 (PDT)
On Apr 7, 3:26 pm, hende...@xxxxxxxxx wrote:
Gang,
I am trying to use scp with an expect script but for some reason
scp will start to copy for a second or two, then just stops (showing
the "failed 1" send_user text). If I run scp from the command line,
all works just fine. I tried searching Google groups and didn't find
anything that helps. Below is the expect script. Let me know any
other information you may require. Using Kubuntu 8.10.
Thanks,
Dave
#!/usr/bin/expect -f
foreach {verbose host port username password action value destination}
$argv {break}
log_user 1
set prompt "(%|#|>|\\$) ";
proc useSCP {prompt verbose host port username password value
destination} {
if {$verbose eq "1"} { send_user "scping to the remote node: " }
if {$destination eq ""} {
# spawn -noecho scp -P $port -p -q "$value" $username@$host:
# spawn scp -P $port -p "$value" $username@$host:
spawn scp -P 22 -p /mnt/data/testing/test\ tarball.tar
a...@xxxxxxxxxxx:
} else {
spawn -noecho scp -P $port -p -q "$value" $username@$host:
$destination
}
expect {
-re "Are you sure you want to continue connecting (yes/no)?" {
if {$verbose eq "1"} { send_user "\[accept key\] " }
send "yes\r"
}
"assword: " {
if {$verbose eq "1"} { send_user "\[authenticating\] " }
send "$password\r"
}
timeout {
if {$verbose eq "1"} { send_user "\[failed\]\n" }
return 0
}
eof {
if {$verbose eq "1"} { send_user "\[failed\]\n" }
return 0
}
}
expect {
-re "o such file or directory" {
if {$verbose eq "1"} { send_user "\[failed\]\n" }
send_user "The file you are trying to send does not exist.
\n"
close
exit 1
}
"assword: " {
if {$verbose eq "1"} { send_user "\[authenticating\] " }
send "$password\r"
}
timeout {
if {$verbose eq "1"} { send_user "\[failed 1\]\n" }
return 0
}
eof {
if {$verbose eq "1"} { send_user "\[success\]\n" }
return 0
}
}
expect "assword: " { # if
we make it down here, we have failed for sure
if {$verbose eq "1"} { send_user "\[failed 2\]\n" }
send_user "Either the password is incorrect or the user
account doesn't exist on the remote node.\n"
close
exit 1
}
if {$verbose eq "1"} { send_user "\[success\]\n" }
return 1
}
if {$action eq "xfer"} {
set retval [useSCP $prompt $verbose $host $port $username $password
$value $destination]
set spawn_id $retval;
exit 0
}
bump for help
.
- References:
- scp failing
- From: hendedav
- scp failing
- Prev by Date: Re: scp failing
- Next by Date: Re: scp failing
- Previous by thread: Re: scp failing
- Next by thread: Re: scp failing
- Index(es):
Relevant Pages
|