I would like to initiate a telnet session, send a command, and store the output in a variable using bash. To do this manually, I do:
telnet ip port >command1
However, I'm not sure how to script this. I could easily echo something if I was just retrieving the output of something directly with
command1, but I'm not sure how to bring the telnet connection into the equation.
I've tried the following command:
command1 | telnet ip port
This seems to start the telnet session, but then it tells me that the command was not found