Linux Shell Script错误:' Uexpected Redirection'

时间:2016-09-13 21:23:38

标签: linux shell curl openwrt

我有一个运行OpenWRT的Linux系统。我正在尝试将shell脚本发布到远程服务器,然后将返回字符串拆分为数组。当我尝试运行它时出现以下错误:"第18行:语法错误:意外重定向"我知道之前已经问过这个问题,但是所有的解决方案都指出它是一个bash语法问题。所以我改变了#34;#!/ bin / sh"到"#!/ bin / ash"并且无法修复它。我是OpenWrt的新手。

脚本:

#!/bin/ash
#SetupScript
LAN_IP="$(ifconfig | awk 'FNR==31 {print $2}')"
SerialNo="$(cat /etc/config/example/ID/device_ID.txt)"
curl --request POST 'https://example.com/op_scripts/SetupRequest.php' --data "my_key=mykey" --data "serial=$SerialNo" --data "lan_ip=$LAN_IP"

SetupReply="$(curl http://example.com/resource)"

if [[ "$SetupReply" = *"false" ]]
then
echo 'setup_failure'
else
OIFS="$IFS"
IFS=':'
read -r -a SetupVals <<< "${SetupReply}"

echo ${SetupVals[0]} > /etc/config/FilterWatch/network/curr_http_port
echo ${SetupVals[1]} > /etc/config/FilterWatch/RunTime/RemoteDatabases/db_name
echo ${SetupVals[2]} > /etc/config/FilterWatch/RunTime/RemoteDatabases/db_username
echo ${SetupVals[3]} > /etc/config/FilterWatch/RunTime/RemoteDatabases/db_password
echo 'completed'
IFS="$OIFS"
fi

0 个答案:

没有答案