Linux 如何在shell脚本中运行此命令
这是我的shell脚本,但它给出了错误:Linux 如何在shell脚本中运行此命令,linux,shell,x264,mplayer,Linux,Shell,X264,Mplayer,这是我的shell脚本,但它给出了错误: #!/bin/sh while getopts "i:o:" flag do case $flag in i) file_input=$OPTARG ;; o) file_output=$OPTARG ;; esac done mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m \ --crf 20
#!/bin/sh
while getopts "i:o:" flag
do
case $flag in
i) file_input=$OPTARG
;;
o) file_output=$OPTARG
;;
esac
done
mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m \
--crf 20 --threads auto --output $file_output - ) $file_input
错误消息是:
无法获取内存或文件句柄来写入“>(x264--demuxer y4m--crf 20--threads auto--output video.264-”!致命:无法初始化视频驱动程序
当我在putty上运行此cmd时:
mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m \
--crf 20 --threads auto --output video.264 - ) video.wmv
它工作得很好
我做错了什么?您使用的命令使用了复杂的bash语法,即
>()
来实现您想要的功能。可能您的/bin/sh
(您在shebang中作为此脚本的shell调用)与您交互使用的shell(即bash)不一样。您使用的命令使用复杂的bash语法,即()
来实现您想要的功能。您的/bin/sh
(您在shebang中作为此脚本的shell调用)可能与您交互使用的shell(即bash)不同。我建议您添加一些”
,以保护您的特殊角色:
mplayer -nosound -benchmark -vo 'yuv4mpeg:file=>(x264 --demuxer y4m --crf 20 --threads auto --output $file_output - )' $file_input
我建议您添加一些
”
,以保护您的特殊字符:
mplayer -nosound -benchmark -vo 'yuv4mpeg:file=>(x264 --demuxer y4m --crf 20 --threads auto --output $file_output - )' $file_input
进程替换操作符是特定于Bash的。如果Bash被称为/bin/sh
,它也不可用,因为在这种情况下,Bash将自身限制为其特性的更兼容的子集
只要使用#/bin/bash
而不是#/bin/sh
在脚本的开头。进程替换操作符是特定于Bash的。如果Bash被称为/bin/sh
,它也不可用,因为在这种情况下,Bash将自身限制为其特性的更兼容的子集
只要使用
#/bin/bash
而不是#/bin/sh
在脚本的开头。/bin/sh可能是指向/bin/bash的链接,但在/bin/sh的名称下,bash的功能并非全部可用,而且特别不支持“=>
”符号。@Jonathan:没有=>
符号。=
是mplayer命令的一部分<代码>>(…)是Bash解析的内容。不总是这样。现在Ubuntu和Debian很流行,/bin/sh
通常是用dash实现的,dash是一个非常简单的严格兼容POSIX的shell。@thkala:你可能是对的-问题开始于=和>,并且/bin/sh不喜欢它,而/bin/bash喜欢它。所以它又是“进程替换”了……这是有道理的。/bin/sh可能是/bin/bash的链接,但在/bin/sh这个名称下,bash的所有功能都不可用,尤其是“=>
”符号不受支持。@Jonathan:没有=>
符号。=
是mplayer命令的一部分<代码>>(…)是Bash解析的内容。不总是这样。现在Ubuntu和Debian很流行,/bin/sh
通常是用dash实现的,dash是一个非常简单的严格兼容POSIX的shell。@thkala:你可能是对的-问题开始于=和>,并且/bin/sh不喜欢它,而/bin/bash喜欢它。所以这又是“流程替代”了…有道理。所有的解决方案都不是功能性的。所有的解决方案都不是功能性的。。