我希望这对大师来说是一个简短的问题。 我有以下命令,该命令在命令行中效果很好:
src/protected/yiic shell src/index.php <<< createmvp < /dev/tty
此命令执行 yiic bash 脚本并向其传递参数 shell 和 src/index.php。
第一个 <<< 将参数 createmvp 传递到终端提示符,该提示符在 yiic shell src/index.php 单独运行时显示。
第二个 < 然后允许 std in 返回到应用程序。
但是当我在 bash 脚本中运行它时
#!/bin/bash
src/protected/yiic shell src/index.php <<< createmvp < /dev/tty
该脚本不会将 createmvp 传递到 shell 中。 如果我删除
while(!isset($input))
{
$input = trim(fgets(STDIN));
if(!$input)
echo "$configVar can not be NULL";
}
关于如何使这项工作像从命令行一样工作,有什么想法吗?
提前致谢
艾伦
最佳答案
(echo createmvp; cat /dev/tty) | src/protected/yiic shell src/index.php
我认为原因是<<< createmvp < /dev/tty
不起作用是因为 <<<
和<
是指定标准输入源的方法,但您不能同时执行这两种操作。 <<<
接受一个字符串作为参数并将其传递给 stdin 而 <
获取一个文件。
关于linux - Bash 重定向和标准输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12918815/