Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 3567

Programming • [Bash] Script to auto shutdown/wake no longer works after move from Ubuntu.

$
0
0
Hello, welcome to the forums!

Code:

Apr 01 19:40:51 debian wake.sh[443]: /usr/local/bin/wake.sh: line 76: [: too many arguments
line 76 is

Code:

if [ $(curl -s --user $tvh_login:$tvh_password http://127.0.0.1:9981/status.xml | grep "subscriptions" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}') -ne 0 -a $shutdown_timer -eq 0 ]; then
A simplified code that satisfies both conditions is

Code:

if [ 1 -ne 0 -a 0 -eq 0 ]; then echo "shutdown_timer set to 1"; fi
The second condition cannot raise an error because shutdown_timer is initialized as an integer before in the code. Therefore, the reason comes from something in the first condition that may prevent this expression from generating an integer.
You can simulate a similar error like this:

Code:

$> shutdown_timer="0"$> unset testvar$> [ $testvar -ne 0 -a $shutdown_timer -eq 0 ]bash: [: too many arguments
So you have to find what can trigger this error in this expression:

Code:

curl -s --user $tvh_login:$tvh_password http://127.0.0.1:9981/status.xml | grep "subscriptions" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'
  • Is curl installed?
  • Are tvh_login and tvh_password set correctly in the script?
  • Is your local server working properly? You can test if it works:

Code:

$> curl -s --user YOURtvh_login:YOURtvh_password http://127.0.0.1:9981/status.xml
  • If it works, does this output a single line:

Code:

$> curl -s --user YOURtvh_login:YOURtvh_password http://127.0.0.1:9981/status.xml | grep "subscriptions"
  • And finally, does this output a single number:

Code:

curl -s --user YOURtvh_login:YOURtvh_password http://127.0.0.1:9981/status.xml | grep "subscriptions" | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'
The script you are using was not designed to account for possible errors.

Statistics: Posted by fabien — 2024-04-01 22:52 — Replies 1 — Views 34



Viewing all articles
Browse latest Browse all 3567

Trending Articles