I am trying to write an ASH script to run on my OpenWRT router.
I have installed onto it nodogsplash, which displays a login page when you first try to authenticate with the router.
nodogsplash comes with a command line utility which allows you to change the password:
ndsctl password newpassword
So I am trying to write a script which I can setup as a cron job to run once a day to change the password to something new, however I am struggling to get it to output correctly. My script atm:
#!/bin/ash
local randompassLength
local pass
randompassLength=8
pass=</dev/urandom tr -dc A-Za-z0-9 | head -c $randompassLength
ndsctl password "$pass"
When I run this I get the output:
miqM2Ah6Password set to .
Which seems to chuck the password at the start of the echo and set the password to blank.
Any ideas what I am doing wrong here?
You’re missing command substitution:
or using backquotes: