1

I currently have a tcl script that is sending a .tar.gz to a remote server.

spawn scp -r "file_to_send.tar.gz" $user@$host:/
set timeout 10

spawn ssh $user@$host
expect "password: "
send -- "$passwd\r"

send -- "tar -zxvf /file_to_send.tar.gz\r"
sleep 1

However, it seems like my extract doesn't work because the scp didn't fully complete. Is there a way to programmatically check when the scp is complete?

  • Can that comment be completed in 10 seconds? – glenn jackman Aug 31 '16 at 18:39
3

You can wait for the first spawn to finish by following it with

expect eof

or if you prefer you can capture and test the return code

catch wait result
if [lindex $result 3] { send_user "fail\n";  exit 1 }
send_user "ok\n"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.