0

現在、bash で次のコマンドを入力する際に​​問題が発生しています。

RESPONSE=`curl -k "$line" --cert=\"$certfile:$certpassfile\" --silent --write-out --head '%{http_code}\n'`

ここ$lineで、 は URL、$certfileは pem ファイルへのパス、$certpassfileは証明書のパスワードです。

次のエラーが表示されます。

++ curl -k url '--cert="/certpath:certpassword"' --silent --write-out --head '%{http_code}\n'

curl: オプション --cert="/certpath:certpassword": 不明

証明書ファイルを二重引用符で囲み、エスケープしない場合、コマンドは次のようになります。

RESPONSE=`curl -k "$line" --cert="$certfile:$certpassfile" --silent --write-out --head '%{http_code}\n'`

同じエラーが表示されますが、パスが異なります。

++ curl -k url --cert=/certpath:certpassword --silent --write-out --head '%{http_code}\n' curl: オプション --cert=/certpath:certpassword: 不明

コマンドを作成する方法は次のとおりです。

curl -k url --cert="/certpath:certpassword" --silent --write-out --head '%{http_code}\n'
4

1 に答える 1

2

--certと値の間の等号を削除する必要があると思います。

RESPONSE=$(curl -k "$line" --cert "$certfile:$certpassfile" \
                --silent --write-out --head '%{http_code}\n')
于 2013-11-05T14:31:48.183 に答える