Domanda

So - I'm using proc_open() to execute programs such as ssh, rsync, scp etc. to perform backup tasks.

However, in some cases, these processes could become interactive and require input, for example when public key authentication fails for SSH, and it asks for a password. This is a major problem because it's out of the question to let a backup job hang, and worse yet, not generate an error.

How do I get completely rid of interactivity in the processes I'm running? If the process suddenly requires input, I want to bail out and generate an error immediately. A generic time-out is not a solution, because the backup processes could take a very long time in normal operation. I'd really need a generic solution to this problem.

Thanks!

È stato utile?

Soluzione

Just pass an empty file as stdin:

 $r = proc_open('cat', [fopen('/dev/null', 'rb')], $p);
 proc_close($r)

This scripts ends in a few miliseconds.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top