从php cli脚本如何调用另一个交互式脚本?

时间:2013-01-17 04:36:57

标签: php shell command-line-interface interactive

例如最小的脚本:

#!/usr/bin/php 
<?php

# do some stuff and then drop into another interactive script:
system('something.sh');

'something'可以是bash,binary等等,无论是什么,都是交互式的,比如sql / telnet / etc.在bash中,这是微不足道的。这甚至可能在php内部吗?

我已经尝试过system(),exec(),passthru(),shell_exec()

proc_open()看​​起来可能但设置起来很乱。

1 个答案:

答案 0 :(得分:0)

如果您想要互动,proc_open() 完全您需要的内容。

如果我没记错的话,这是获得子进程的STDIO的唯一方法,如果你重定向输入/输出,你将需要它。

相关问题