Skip to main content
Commonmark migration
Source Link

My man page for expect says:

exit [-opts] [status]

 

[...] status (or 0 if not specified) is returned as the exit status of Expect.

So you simply want exit 1.


As for your three alternatives, expect eof would wait for the command expect is talking with to reach EOF. You might continue the expect script after that. expect eof is useful in cases where that's just one of the options, or when the remote might detect the disconnection and take it as an error. (Of course if both sides of the conversation wait for the other to stop, then they're stuck.)

close would close the connection to the other process, so in sense acting as the reverse of expect eof. Again, your script could continue after this. Using close just before exiting the script doesn't do much, as an exit will also implicitly close.

Then there's exit that exits your script. Choosing between the three depends on what you want to do. If you want to exit, I'd say just exit, and let the remote deal with the EOF.

My man page for expect says:

exit [-opts] [status]

 

[...] status (or 0 if not specified) is returned as the exit status of Expect.

So you simply want exit 1.


As for your three alternatives, expect eof would wait for the command expect is talking with to reach EOF. You might continue the expect script after that. expect eof is useful in cases where that's just one of the options, or when the remote might detect the disconnection and take it as an error. (Of course if both sides of the conversation wait for the other to stop, then they're stuck.)

close would close the connection to the other process, so in sense acting as the reverse of expect eof. Again, your script could continue after this. Using close just before exiting the script doesn't do much, as an exit will also implicitly close.

Then there's exit that exits your script. Choosing between the three depends on what you want to do. If you want to exit, I'd say just exit, and let the remote deal with the EOF.

My man page for expect says:

exit [-opts] [status]

[...] status (or 0 if not specified) is returned as the exit status of Expect.

So you simply want exit 1.


As for your three alternatives, expect eof would wait for the command expect is talking with to reach EOF. You might continue the expect script after that. expect eof is useful in cases where that's just one of the options, or when the remote might detect the disconnection and take it as an error. (Of course if both sides of the conversation wait for the other to stop, then they're stuck.)

close would close the connection to the other process, so in sense acting as the reverse of expect eof. Again, your script could continue after this. Using close just before exiting the script doesn't do much, as an exit will also implicitly close.

Then there's exit that exits your script. Choosing between the three depends on what you want to do. If you want to exit, I'd say just exit, and let the remote deal with the EOF.

Source Link
ilkkachu
  • 148.1k
  • 16
  • 268
  • 441

My man page for expect says:

exit [-opts] [status]

[...] status (or 0 if not specified) is returned as the exit status of Expect.

So you simply want exit 1.


As for your three alternatives, expect eof would wait for the command expect is talking with to reach EOF. You might continue the expect script after that. expect eof is useful in cases where that's just one of the options, or when the remote might detect the disconnection and take it as an error. (Of course if both sides of the conversation wait for the other to stop, then they're stuck.)

close would close the connection to the other process, so in sense acting as the reverse of expect eof. Again, your script could continue after this. Using close just before exiting the script doesn't do much, as an exit will also implicitly close.

Then there's exit that exits your script. Choosing between the three depends on what you want to do. If you want to exit, I'd say just exit, and let the remote deal with the EOF.