Hi there,
I’m experiencing very strange behavior with the inventory script below. (mycommand returns the following same JSON assigned to the vitals2 variable)
#!/bin/bash
vitals=$(mycommand)
echo "vitals='${vitals}'"
echo "vitals='{\"\":{\"info\":{},\"last_status\":{\"free\":-1,\"usage\":-1}},\"cpu_info\":{\"info\":{},\"last_status\":{\"free\":77.29083251953125,\"usage\":22.709163665771484}},\"ext_comp_info\":{},\"firmware_info\":{\"info\":{\"version\":\"v2.0.1-rc13\"},\"last_status\":{}},\"hdd_info\":{\"info\":{\"brand\":\"M62704\",\"model\":\"none\",\"serial\":\"0x164db72c\"},\"last_status\":{\"free\":54.70341873168945,\"free_raw\":1955632,\"usage\":45.29658126831055,\"usage_raw\":1619340}},\"os_info\":{\"info\":{\"arch\":\"armv7l\",\"dist_info\":\"#1SMPPREEMPTTueJul222:57:18+032019\",\"endianness\":\"little\",\"kernel_version\":\"4.14.108-ti-r108\",\"machine_name\":\"centrisv2\"},\"last_status\":{}},\"ram_info\":{\"info\":{},\"last_status\":{\"free\":66.53024291992188,\"free_raw\":330980,\"usage\":33.46975326538086,\"usage_raw\":166508}},\"swap_info\":{\"info\":{},\"last_status\":{\"free\":null,\"free_raw\":0,\"usage\":null,\"usage_raw\":0}},\"thermal_info\":{\"info\":{},\"last_status\":{\"temperature\":0}},\"uptime_info\":{\"info\":{},\"last_status\":{\"currentEpoch\":1623409763653,\"deviceDate\":\"11.06.2021\",\"deviceTime\":\"14:09:23\",\"uptime\":\"2325739\"}}}'"
And here’s the script output and Mender screenshot.
So as you can see from the script, on the third line I get the command output and echo it, and on the next line, I copied the command output and assigned it to the vitals2 variable and echoed it as well. The script output is shown in the first image.
The issue is vitals variable shown empty on the Mender while vitals2 has the proper content.
Any ideas?