0

For example, I've executed a script using nohup and & to put the script execution in background, and in some step the script ask me to do something else to be able to continue the current execution, and also it ask to confirm if I've done it typing enter or another key. Is there some way to do it?

2
  • When you run nohup you close the standard input (and standard output). You could duplicate them and keep it hand for when interaction is needed, but that kind of defeats the purpose. Why are you using nohup? – Eduardo Trápani Jan 11 at 20:17
  • Perhaps substitute using screen instead of nohup, if interaction is needed/expected. – mrflash818 Jan 11 at 23:15
1

answer to your explicit question

Yes, there is a way to script console interaction: Expect. Quite a few resources out there (https://core.tcl-lang.org/expect/index seems to be a good starting point); Exploring Expect by Libes (ISBN 9781565920903) is a fine book on the subject.

A special case: if there is only one thing to enter from keyboard (say “foo”), you might be able to get away with one of the following tricks (and not have to learn Expect just for this one task!):



answer to (what seems to be) your implied question

Is there a way to just provide responses up front, and avoid the bother?? Maybe. The tool you're dealing with might have an option for noninteractive execution; read the usage instructions carefully, in case such an option is there and you haven't noticed it. I've seen noninteractive execution option called different things; look for

  • “headless”
  • “noninteractive”
  • “responsefile”
  • “silent”
  • --assumeyes
  • --preconfig
  • -y

Doubtless other contributors can provide additional examples.

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.