Hey there, I'm a newbie at this thing, so please forgive me for my lack of knowledge... So I recently made a custom script to turn my router's LEDs off and on, and the way I planned to do it was to make two UCI scripts first and then run the scripts from the Scheduler crontab. I've already made sure the scripts are executable (I guess, I mean the text on the script files turned green after I chmod +x ed it) but whenever I try to execute it, I get greeted with this message saying, "-ash: ./led_schedule_off.sh: not found." Did I do something wrong in the scripts that's causing this error? TYIA
#!/bin/sh
# Turn off LEDs
uci set system.led_wan.trigger='none'
uci set system.led_lan.trigger='none'
uci set system.cfg058bba.trigger='none'
uci set system.cfg068bba.trigger='none'
uci set system.cfg078bba.trigger='none'
uci commit
2)led_schedule_on.sh
#!/bin/sh
# Turn on LEDs
uci set system.led_wan.trigger='netdev'
uci set system.led_wan.dev='wan'
uci add_list system.led_wan.mode='tx'
uci add_list system.led_wan.mode='rx'
uci set system.led_lan.trigger='default-on'
uci set system.cfg058bba.trigger='default-on'
uci set system.cfg068bba.trigger='default-on'
uci set system.cfg078bba.trigger='heartbeat'
uci commit
Hey guys! A quick follow up... I actually managed to run the script by typing sh led_schedule_off.sh
BUT now I'm facing an even weirder problem where the script actually executes and all but the actual LEDs on my router are not turning off as expected. Now the way I figured out the script was working was I went to System>Led Configuration tab and saw the default state of all LEDs showing "none" and whenever I try to hit "Save & Apply" it hits me back saying "There are no changes to apply." Now initially, I made sure to include uci commit at the end of my scripts that should've saved and applied... so did I miss some other codes that I should've included? Thank You For Your TIme.
Hey folks! This is going to be my last follow-up on this topic. I finally managed to run the scripts, and it worked as intended! All this time, all I needed was to restart the LEDs after uci committing . But it's finally working, and now all I need to do is wait to see if the crontab works. Here are the final codes after a little bit of tweaking,
1)led_schedule_off.sh:
#!/bin/sh
uci set system.led_wan.trigger='none'
uci set system.led_wan.default='0'
uci set system.led_lan.trigger='none'
uci set system.led_lan.default='0'
uci set system.cfg058bba.trigger='none'
uci set system.cfg058bba.default='0'
uci set system.cfg068bba.trigger='none'
uci set system.cfg068bba.default='0'
uci set system.cfg078bba.trigger='none'
uci set system.cfg078bba.default='0'
uci commit
/etc/init.d/led restart
2)led_schedule_on.sh:
#!/bin/sh
uci set system.led_wan.trigger='netdev'
uci set system.led_wan.dev='wan'
uci add_list system.led_wan.mode='tx'
uci add_list system.led_wan.mode='rx'
uci set system.led_lan.trigger='default-on'
uci set system.cfg058bba.trigger='default-on'
uci set system.cfg068bba.trigger='default-on'
uci set system.cfg078bba.trigger='heartbeat'
uci commit
/etc/init.d/led restart
I wish I could change the title of the topic to "custom LED scheduling script not running (TP Link Archer C6 v3.20)" so people can find the post easily. But I can't. Anyway, dear admins you can close this topic off. Thank you all for your time!
Besides that's cool that you've figured out how to trigger your LED i think I'm not alone thats puzzling why the shell was not able to execute the script.
wait, so my command was right? Damn, now I'm also confused as to why it worked with sh led_schedule_off.sh and not ./led_schedule_off.sh. is there a way to see the logs that can help us see why it showed "not found?"
No. It's not required... But I assume its only valid for scripts in the same language as the current shell...
root@cpe:~# vim /tmp/test.sh
root@cpe:~# cat /tmp/test.sh
test 1 && echo "yeah!"
echo "nope. you don't even need a shebang!"
exit 1
root@cpe:~# chmod +x /tmp/test.sh
root@cpe:~# /tmp/test.sh
yeah!
nope. you don't even need a shebang!
I was curious as to whether it was line endings, so I ran your test with dos (CRLF) and mac (CR), too. They both ran, albeit the mac line endings mashed everything onto one line and the script output was, uh, not great.
I was surprised to see that Busybox ash handles dos line endings without a whimper, as Python and bash are very sensitive about such things.
$ bash ./test.sh
./test.sh: line 1: $'\r': command not found