Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using an expect script to connect to a windows machine and execute an ant script. After completion I want to delete a file and log out. The execution of the ant script takes almost 30 seconds, so I added a "sleep 40" to the expect script. But what if the execution time will be much longer? Is there a way to let the expect script wait without using the sleep command?

share|improve this question
I don't think anyone will be able to answer you with that little information. How about showing the current script? – geirha May 25 '12 at 16:22

Yes, ofcourse you can, why don't you see what is outputed to the screen after the script has finished ? For example:

expect "ssh:/C/remoteWindows/myfolderwithantscript/$"
send "rm a_file.txt"

where ssh:/C/remoteWindows/myfolderwithantscript/ is the text you get after the scipt finishes, on a linux machine is something like this: /home/alex/Documents$ for example, and then you send the 'rm' command to remove the file.

This is what I do so as to upload a file to an ftp server. I just do a

expect "sftp>"

and then proceed to the next steps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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