how to set a telnet variable

view story

http://stackoverflow.com – I need to create a script in Linux to telnet some machines, The point of the script is to create a log file saying which machines were online and which were not. So, What came to my mind is to telnet each machine and create a variable with the result. If the variable exists then redirect it to a file. Something like x=$(telnet if x=true then echo x > file.txt done (HowTos)