I created a custom script for reporting measured Internet speed on 19.07.3 to an external server. The line in question is:
logger "The measured speed is: DL="$measured_dl"Kbps and UL="$measured_ul"Kbps."
When run by CLI works perfectly, i.e. router: The measured speed is: DL=abcdKbps and UL=wxyzKbps.
but when run in the ash script, inserts an unwanted blank_space between the variables and the rest of the text. i.e. router: The measured speed is: DL=abcd Kbps and UL=wxyz Kbps.
Thanks @anon50098793 for leading me in the right direction. Actually, the space was not in my variables, and what you suggested insert double_quotes before and after the variables:
But, after fiddling with it for a little bit, I came to an scape sequence that works from the CLI: logger The measured speed is: DL=$measured_dl\Kbps and UL=$measured_ul\Kbps.
Nevermind: I wrote too quickly: after running the actual script with the scape codes \, it still inserts the blank space between the variables and the Kpbs.
So the issue remains open.
hmmm... looks like some whacky shell IFS or something... works for me;
#################### cat loggertest.sh
measured_dl=100
measured_ul=200
logger "The measured speed is: DL="$measured_dl"Kbps and UL="$measured_ul"Kbps."
logread | tail -n1
########[root@rpi-dca6325 /usbstick 45°]# ./loggertest.sh
user.notice root: The measured speed is: DL=100Kbps and UL=200Kbps.
i'm guessing your getting those variables from some commands output / sysfs etc. and you'll likely need to use sed/tr to strip the "non-visible" ammendums.
But you are doing this on your local router dir, right? I'm using an external log server.
I've done the same in dd-wrt and works perfectly for their busybox bash. I'm still fighting with my OpenWrt busybox ash. From my OpenWrt CLI, works fine, only fails when I run it from my crontab script.
What bugs me, is it runs OK from CLI to the free papertrailapp log server, but not when run from the script.
In fact, with dd-wrt I haven't needed to scape the characters.
Wait, please not so fast. I calculated the variable as: measured_dl=$((received_2-received_1)*8/time/1000)
How the 0D got there I don't know, but how can I rephrase my equation, please?
Actually, there was no need to do any other change. I found somehow my Notepad++ was causing the error, as I edited the script directly on the router and now it works fine. In fact, my original script should have worked as intended.
Anyways, thanks for your support. I will mark this thread as solved.