I'm running a very simple telnet bash script and it works.
#!/bin/sh
host=90.205.177.129
port=23
login=admin
passwd=Sky.2015
#cmd1=sh
cmd2=meminfo > /tmp/top.txt
echo open ${host} ${port}
sleep 5
echo ${login}
sleep 5
echo ${passwd}
sleep 10
#echo ${cmd1}
#sleep 5
echo ${cmd2}
sleep 20
echo exit
However, the output of meminfo is not copied on "top.txt" file. The file is created
root@raspberrypi:/etc/my_scripts# ls -l /tmp/
total 12
-rw-r--r-- 1 root root 784 Oct 13 14:32 1wall_test1_S.txt
-rw-r--r-- 1 root root 216 Oct 14 11:28 test_l.txt
-rw-r--r-- 1 root root 216 Oct 14 11:37 test_s.txt
-rwxrwxrwx 1 root root   0 Oct 15 09:35 top.txt
root@raspberrypi:/etc/my_scripts#
Any suggestion?
echo $foois noteval "echo $foo".expectis a better tool for this job thanbash. e.g. see unix.stackexchange.com/questions/184666/…