dietpi-cloudshell syntax error - HELP

Please see this thread at odroid forum for the CloudShell XU4: [SOLVED] dietpi-cloudshell syntax error - ODROID

The cloudshell no longer displays correctly. I’ve even re-imaged and the error is still present.

Since dietpi build v116, the cloushell lcd has been displaying an error.

/DietPi/dietpi/dietpi-cloudshell: line 479: * : syntax error: operand expected (error token is "* ")
cloudshell_error.JPG
Line 479 from my cloudshell file:

Code: Select all

                    NETWORK_USAGE_TOTAL_CURRENT_RECIEVED=$(( $(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $4}') * $mtu_size ))
                    NETWORK_USAGE_TOTAL_CURRENT_SENT=$(( $(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $8}') * $mtu_size ))

I tried replacing the "* " on line 479 with “1500”. Got an error then for Line 480 but not 479! Changed line 480 to 1500 also but then got the new error in the second screenshot!!!
cloudshell_error2.JPG
I changed the 1500 back to * and rebooted. The original error returned. The only temporary fix I was able to find was to open the terminal window, launch dietpi-cloudshell, and tab down to “Start / Restart Apply settings. Launch on Main screen (tty1)” and hit enter. Screen then displays as normal without the error. The error does NOT come back until I need to reboot. I’ve uninstalled cloudshell and reinstalled. Error still persists. Now I’ve gone to github and looked at the original code for v116, v117, and v118. Line 479-480 is exactly the same as it shows at GitHub!

Ideas???

I don’t know much about ODROID - but the syntax error seems like it’s because the left-hand side of the $(( ValueA * ValueB)) is being evaluated as null on reboot, and the error is because Bash is seeing the “*” first - and, well, you will want an operand (packets transferred) before a mathematical expression, as the error says. Think of it as: $(( 5 * 3 )) would be 15, but $(( * 3 )) or $(( * )) makes no sense - and removing the * only confuses the issue.

My gut is that if you’re seeing this on every reboot, the script is running before the eth0 network interface is up - netstat and grepping for “eth0” returns nothing - and so the variable(s) being used in the syntax get assigned to NULL and aren’t getting re-evaluated. But I’m guessing without facts, and would defer to any experts here on the matter.

Hi,

Many thanks for the report.

I’ve created a Git Ticket for this issue: https://github.com/Fourdee/DietPi/issues/355 . Will try and look into this today/tomorrow.

I tried replacing the "* " on line 479 with “1500”. Got an error then for Line 480 but not 479! Changed line 480 to 1500 also but then got the new error in the second screenshot!!!

Very good debugging, I came to the same tests :smiley:

My gut is that if you’re seeing this on every reboot, the script is running before the eth0 network interface is up

I think your spot on.
I’ll setup a C2 disable eth0 and modify dietpi-cloudshell source to force use eth0. If it replicates the same error, should be an simple sourcecode fix.

Was able to replicate the issue by just setting wlan0, on a C2 with only eth0 active:

		local mtu_size=$(netstat -N -i | grep wlan0 | awk '{print $2}')
		NETWORK_USAGE_TOTAL_CURRENT_RECIEVED=$(( $(netstat -N -i | grep wlan0 | awk '{print $4}') * $mtu_size ))
		NETWORK_USAGE_TOTAL_CURRENT_SENT=$(( $(netstat -N -i | grep wlan0 | awk '{print $8}') * $mtu_size ))

So I need to add some code that checks for connection, or, valid integer, in the above lines:

Will let you know when its done :slight_smile:

Ok, added a valid integer check, before the scene is updated:

		local mtu_size=$(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $2}')
		if [[ ! $mtu_size =~ ^-?[0-9]+$ ]]; then
			run_update=0
		fi

		local network_usage_current_recieved=$(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $4}')
		if [[ ! $network_usage_current_recieved =~ ^-?[0-9]+$ ]]; then
			run_update=0
		fi

		local network_usage_current_sent=$(netstat -N -i | grep "$NETWORK_DETAILS_ADAPTER" | awk '{print $8}')
		if [[ ! $network_usage_current_sent =~ ^-?[0-9]+$ ]]; then
			run_update=0
		fi

We could probably get away with just checking for one valid integer from scrape (eg: network_usage_current_recieved). But there is no harm in checking all variables used in our calculations have a valid integer, before we use them.

You can install the updated version of DietPi-Cloudshell by running:

wget https://raw.githubusercontent.com/Fourdee/DietPi/f003529ccc6c89c8dcb3235fe0b3618353f156bb/dietpi/dietpi-cloudshell -O /DietPi/dietpi/dietpi-cloudshell

Please let me know if the issue is resolved.

It has cycled through a couple of times and no errors show up! I will keep an eye on it for the next 12hrs and post one last update to see how it fairs through the night. I don’t see any further issues with this particular hiccup. This is excellent!!! Thank You :smiley:

Hi Erik,

Many thanks for the update and results. As you mentioned, If all is good after your 12h test, please let me know, i’d be grateful.

Ok, so…

No error, it has not returned! However, a minor item has surfaced. This may need to go into a separate thread. Please let me know.

While I didn’t quite make it to 12hrs due to thunderstorms that have been non-stop for the last 8-9hrs, so I unplugged everything. The one thing I have notice is that the IP address and MAC address will not populate until I have accessed a session through SSH. I noticed that last night and I tested it again this morning when I turned everything back on. I let it set for 90min before accessing SSH. IP and MAC did not populate until I did so. Not an issue for me but a minor bug that could easily be overlooked otherwise.

Thanks.

New thread for above items that have surfaced after the syntax error fix: http://fuzon.co.uk/phpbb/viewtopic.php?f=11&t=443

Thanks.

Thanks Erik, i’ll take a look.