Passing Return Key via Shell Script

2

I'm using phpseclib to run a shell script on my server at a given interval. That script involves using nohup. For whatever reason, if there isn't a user ready to send SIGINT or a return to nohup once it's launched, it kills the process.

For instance, if I run the script via a local prompt it runs, then all I have to do is hit enter and I get a new cmd prompt. When I try and run it automatedly, I can't pass the return or a SIGINT and the process never finishes. Ideas?

Peter Kazazes

Posted 2012-11-03T05:39:27.737

Reputation: 205

Have you tried replacing nohup with GNU screen? What function does nohup provide that can't be provided by screen? – allquixotic – 2012-11-03T06:07:22.307

@allquixotic Screen requires an active terminal, and therefore cannot be run solely over an ssh command. – Peter Kazazes – 2012-11-03T17:01:59.417

Are you already aware of the information in this AU post?

– allquixotic – 2012-11-03T19:03:02.333

Answers

0

Normally I've used an ugly TCL/Tk framework called Expect to do this sort of thing in the past. I noticed there is a php version of expect called PHP:Expect. Perhaps that will help here?

Expect should allow you to simulate a console connection and send any key squence. Be warned though these frameworks can be painful. If you aren't tied to PHP take a look at Ashier which sounds awesome (although I've never used it).

Peter Jenkins

Posted 2012-11-03T05:39:27.737

Reputation: 438