在名为“input_data”的bash文件中
LA=$1
curl -H 'Content-Type: application/x-ndjson' -XPOST '"'$LA'":9200/human_flow/human_flow/_bulk?pretty' --data-binary @$2.json
运行命令时
./input_data localhost human_flow
提供错误消息
bash-3.2$ ./input_data localhost human_flow
curl: (6) Could not resolve host: "localhost"
localhost可以解决
bash-3.2$ ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.067 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.156 ms
使用127.0.0.1而不是localhost
bash-3.2$ ./input_data 127.0.0.1 human_flow
curl: (6) Could not resolve host: "127.0.0.1"
答案 0 :(得分:1)
正确用法如下:
curl \
-H 'Content-Type: application/x-ndjson' \
-XPOST \
--data-binary "@$2.json" \
"$LA:9200/human_flow/human_flow/_bulk?pretty"