So i have a ash script that send command to device via telnet
The command look like this.
echo 'dofile("lcdprint.lua").lcdprint("date")' | telnet 192.168.1.23 23
Tue Jul 12 17:10:51 WIB 2016
If you want to incorporate the output from locally executing the
date utility, before sending the command string to the target machine, use
$(...), Bash's command substitution:
echo "dofile('lcdprint.lua').lcdprint('$(date)')" | telnet 192.168.1.23 23
Note how the overall string is double-quoted to ensure that
$(...) is expanded.
If you want to run
date on the target machine, use Lua's
os.execute() to run a shell command:
echo 'dofile("lcdprint.lua").lcdprint(os.execute("date"))' | telnet 192.168.1.23 23
Note how the overall string is single-quoted, because no interpretation by Bash is needed in this case, and using single quotes ensures that the string is passed as-is.