[英]Some questions regarding how to use a shell interactively with another shell in linux
This post is about some automation tasks, and also to satisfy my curiosity. 这篇文章是关于一些自动化任务的,也是为了满足我的好奇心。
Is this scenario possible, can anyone offer any practical pointers? 这种情况是否可能,任何人都可以提供任何实用的指导吗?
Run a shell script 运行一个shell脚本
shell_exec(bash script);
Bash script like: Bash脚本如下:
Write input commands to file for example: 将输入命令写入文件,例如:
I'm going to leave a shameless link to a post where I demonstrate doing this, "expect in php": http://codehackit.blogspot.be/2012/04/automating-command-line-scripts-in-php.html 我将留下一个毫不客气的链接,该文章演示了执行此操作的过程,“在php中期待”: http : //codehackit.blogspot.be/2012/04/automating-command-line-scripts-in-php。 HTML
Basically it's just a wrapper around proc_open(), which returns FDs for writing and reading to another processes stdin/stdout. 基本上,它只是proc_open()的包装,它返回用于写入和读取到另一个进程stdin / stdout的FD。 http://php.net/manual/en/function.proc-open.php
http://php.net/manual/en/function.proc-open.php
In order to avoid problems with partial reads and writes (due to io buffering and races), you may want to consider using a directory the in/out-box like so: 为了避免部分读写问题(由于io缓冲和竞争),您可能需要考虑使用类似in / out-box的目录:
Do likewise for the output files. 对输出文件也同样如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.