I have written the shell script below should be the expected out put
{"lastChecked":1582765938951,"entry":"10.123.45.67:9082","canConnect":true,"httpStatus":0,"httpProxy":null,"responseTime":1,"validUrl":false,"validHostname":true}
When I am trying to execute it was throwing an error
{"timestamp":1582765411548,"status":500,"error":"Internal Server Error","exception":"org.json.JSONException","message":"Missing value at 10 [character 11 line 1]","path":"/v2/willitconnect"}
if I put echo
in front of curl
, then I can it is printing the host and port numbers, once I remove echo then it is not giving me the expected output
This is the script which I have written
#!/bin/bash
# Purpose: Read Comma Separated CSV File
INPUT=Hostnport.csv
OLDIFS=$IFS
IFS=','
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read hostname port
do
echo "hostname : $hostname"
echo "port : $port"
curl -s -k --location --request POST 'https://willitconnect.apps.px-npe01b.cf.t-mobile.com/v2/willitconnect' \
--header 'Content-Type: application/json'
--data-raw {\"target\": \"$hostname:$port\"}\'
done < Hostnport.csv
IFS=$OLDIFS