Re: scp failing



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
.



Relevant Pages

  • scp failing
    ... I am trying to use scp with an expect script but for some reason ... Below is the expect script. ... foreach {verbose host port username password action value destination} ...
    (comp.lang.tcl)
  • Re: scp failing
    ...  Below is the expect script. ... When you run scp from the command line, ... taking out the timeout block does *not* remove ...
    (comp.lang.tcl)
  • Re: scp failing
    ... scp will start to copy for a second or two, ...  Below is the expect script. ... foreach {verbose host port username password action value destination} ...
    (comp.lang.tcl)
  • Re: scripting newb
    ... I was able to hobble this together from another script posted by Dan ... Dim strSearch, strAdsPath, strServerName 'from search script ...     'Prompt for search criteria ... computerName, samAccountName, givenName, sn, AdsPath ...
    (microsoft.public.scripting.vbscript)
  • Re: finding files
    ... I'm back and also my script as changed ever since. ... have to be an Array then.. ... For Each strComputer In arrComputers ...     Function ReadTxtToArray ...
    (microsoft.public.scripting.vbscript)