我试图在bash脚本中运行curl命令,并且我遇到以下错误:
curl: (26) failed creating formpost data
当我回显curl命令并从命令行运行它时,运行没有问题。我确保文件中的每个人及其所在的文件夹都有读取权限,以及使用相对路径和绝对路径。
以下是该脚本的示例:
#!/bin/bash
usage(){
echo "usage: <command> options: <u|p|f> "
}
while getopts u:p:f: option
do
case "${option}"
in
u) USERNAME=${OPTARG};;
p) PORT=${OPTARG};;
f) FILE=$OPTARG;;
esac
done
if [ $OPTIND -eq 1 ]; then
#echo "No options were passed";
usage
exit
fi
echo "Please enter your password: "
read PASSWORD
TEST="curl -u $USERNAME:$PASSWORD -F file=@\"$FILE\" -F force=true -F install=true http://localhost:$PORT/test.jsp"
echo $TEST
$TEST
echo $?
谢谢!