2016-09-22 15 views
-2

私はLinuxの初心者です。 私はターミナルで直接このコマンドを実行することができます。(刻まれた)パラメータ ""付きbashシェルスクリプト

7za t -p' \' -w -y /root/test2.7z | grep -i OK 

私は7zipをファイルのパスワードのテストのために(test_script.shという名前の)スクリプトをしよう:

7za t -p$1 -w -y /root/test2.7z | grep -i OK 

が、このスクリプトで結果を取得することはできません。

sh /root/test_script.sh ' \' 

実行結果:

[[email protected] ~]# sh /root/test_script.sh ' \' 
7za t -p \ -w -y /root/test2.7z | grep -i OK 
ERROR: No more files 
\ 
System ERROR: 
Unknown error 18446744071562526744 

[[email protected] ~]# sh /root/test_script.sh " \" 
> 
> 
> 

ターミナルがぶら下がり、次のコマンドを待っている可能性があります。

パラメータ「\」を渡す方法を教えてください。

+2

'-p" $ 1 "'確かにあなたはあなたの研究でこの提案を実行しました。 – rici

+0

また、http://shellcheck.netは、このようなエラーを検出するためのあなたの友人です... – anishsane

答えて

0

ありがとうございました。 スクリプトが機能しました。 7za t -p "$ 1" -w -y /root/test2.7z | grep -i OK 実行 sh /root/test_script.sh '\'

関連する問題