please advice why
spawn scp $FILE1 $FILE2 $LOGIN@$IP:/tmp
in my expect script copy only FILE1 and not copy FILE2 ?
I try to to transfer both files by scp as
scp file1.csv file2.crt 192.8.200.1:/tmp
without expect and they transferred successfully to /tmp
so why VIA expect the only file that copied is FILE1 ??
what wrong in my syntax ?
example of my expect script:
#!/usr/bin/expect -f
set FILE1 file1.csv
set FILE2 file2.crt
set multiPrompt {[#>$]}
spawn scp $FILE1 $FILE2 $LOGIN@$IP:/tmp
expect {
")?" { send "yes\r" ; exp_continue }
word: {send $PASS\r}
}
I also try this:
spawn scp "$FILE1 $FILE2" $LOGIN@$IP:/tmp
OR
spawn scp '$FILE1 $FILE2' $LOGIN@$IP:/tmp
but I get the same problem
")?"
means "match a close parenthesis followed by any character". Is this what you're intending to match? While you're developing your script, addexp_internal 1
as the first line following the shebang. – glenn jackman Aug 12 '14 at 20:29$FILE1 $FILE2
– glenn jackman Aug 12 '14 at 20:32echo
maybe? What does it print when it runs;spawn
prints its invocation? – eewanco Aug 12 '14 at 20:57-o StrictHostKeyChecking=no
scp option to avoid the first query you're trying to match on and answer (")?
"). Anyexpect
exchange you can avoid will make your script more reliable. What happens if you add the-v
option toscp
? Have you tried changingscp
to/usr/bin/scp
just to be paranoid? – eewanco Aug 13 '14 at 14:26