我正在使用运行命令通过RHEL 7 VM中的Azure CLI bash脚本执行bash脚本。
当运行命令的代码段出现错误:
az vm run-command invoke --name ${THIS_VM_NAME} \
--command-id RunShellScript \
--resource-group ${RSC_GRP_NAME} \
--query "output[].message | join('\n\n', @)" \
--scripts "
cat > /etc/init.d/parity <<'EOF'
${INIT_D_PARITY}
exit 0
EOF
chmod +x /etc/init.d/parity
service parity restart
sleep 5
ls -la /var/log/parity.err
ls -la /var/log/parity.log
ls -la /var/log/parity.node.log
echo '_____________________________________________'
echo 'Parity Error Log:'
tail -n 5 /var/log/parity.err
echo '_____________________________________________'
ls -la /usr/libs/libssl*
parity -v
cat /var/log/parity.node.log | grep -oEi '(enode.*@)' | tail -n 1 | sed 's/enode:\/\///' | sed 's/@.*//' > /etc/parity/enode.pub
ls -la /etc/init.d/parity
ls -la /etc/parity/enode.pub
cat /etc/parity/enode.pub
echo 'Parity is Up an running \o/'
"
这是错误消息:
在函数join()中,值的无效类型:无,应为以下之一: ['array-string'],收到:“ null”回溯(最近一次通话最近):
答案 0 :(得分:0)
join()是JMESPath的功能,它是JSON的查询语言。这是一个简单的示例:
数组:
{
"locations": [
{"name": "Seattle", "state": "WA"},
{"name": "New York", "state": "NY"},
{"name": "Bellevue", "state": "WA"},
{"name": "Olympia", "state": "WA"}
]
}
查询代码:
locations[?state == 'WA'].name | sort(@) | {WashingtonCities: join(', ', @)}
结果:
{
"WashingtonCities": "Bellevue, Olympia, Seattle"
}
对于您的问题,您可以从此link中获取详细信息。我认为如果输出是数组,则函数join()会很好地工作。如果没有,将出现与您相同的错误。