Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在另一个进程内执行命令?_Ruby_Linux_Bash_Ubuntu - Fatal编程技术网

Ruby 在另一个进程内执行命令?

Ruby 在另一个进程内执行命令?,ruby,linux,bash,ubuntu,Ruby,Linux,Bash,Ubuntu,我希望能够启动一个流程并立即向其发送输入 以Bash为例 下面的代码将进入另一个Bash进程,然后在我用“exit”终止进程后在屏幕上打印“helloworld!” 有没有办法进入bash,然后在这个过程中打印“helloworld!” 我在Ubuntu上使用Ruby和Bash 更新:这个问题不是针对Bash的。Bash只是一个例子。如果有人能发布一个处理所有其他二进制文件的答案,那就更好了 bash -c 'echo "Hello World!"' 您还可以尝试编写并调用它: bash ./

我希望能够启动一个流程并立即向其发送输入

以Bash为例

下面的代码将进入另一个Bash进程,然后在我用“exit”终止进程后在屏幕上打印“helloworld!”

有没有办法进入bash,然后在这个过程中打印“helloworld!”

我在Ubuntu上使用Ruby和Bash

更新:这个问题不是针对Bash的。Bash只是一个例子。如果有人能发布一个处理所有其他二进制文件的答案,那就更好了

bash -c 'echo "Hello World!"'
您还可以尝试编写并调用它:

bash ./myscript
或者放
#/bin/bash
作为,它将像任何其他可执行文件一样使用bash调用:

./myscript
更新0 Bash是一个解释器。还有很多其他的口译员,我强烈建议你看一下,你可以很容易地向这些程序发送被翻译的指令

您可能还提到了,在这种情况下,您可能想问一个与使用
stdin
stdout
管道有关的问题

%x(some external bash commands)

`ls -1`
您还可以尝试编写并调用它:

bash ./myscript
或者放
#/bin/bash
作为,它将像任何其他可执行文件一样使用bash调用:

./myscript
更新0 Bash是一个解释器。还有很多其他的口译员,我强烈建议你看一下,你可以很容易地向这些程序发送被翻译的指令


你也可能指的是,在这种情况下,您可能想问一个与管道使用相关的问题,使用
stdin
stdout
您可能正在寻找该工具。

您可能正在寻找该工具。

我不明白这与我的问题有什么关系。请写下有关该语法的更多信息。我不明白这与我的问题有什么关系。请写下有关此语法的详细信息。
%x(some external bash commands)

`ls -1`