I am creating a script for my router (running busybox).
In my script I generate a command in a variable like nvram set option='value with spaces' but when it is executed it complains that arguments are invalid. If I echo the same command and copy/paste it into the terminal it works fine.
#!/bin/sh
client="client1"
option="desc"
value="Client number 4"
cmd="nvram set vpn_${client}_${option}='${value}'"
echo $cmd;
echo `$cmd`;
When running this script, it outputs the following:
nvram set vpn_client1_desc='Client number 4'
usage: nvram [get name] [set name=value] [unset name] [show] [commit] [save] [restore] [erase] [fb_save file]
usage: nvram [save_ap file] [save_rp_2g file] [save_rp_5g file] [save_rp_5g2 file]
The first line is my echo of the command and the two next are output from the nvram set command which complains about the arguments. It works if spaces in the value are omitted.
What am I missing here?
PS. My router is an ASUS RT-AC87U running latest version of Merlin firmware.