title: Automating telnet session using bash scripts
body: <p>I am working on automating some <code>telnet</code> related tasks, using Bash scripts.
  Once automated there will be no interaction of the user with <code>telnet</code> (that is it will be totally automated)</p>
  <p>The scripts looks something like this:</p>
  <pre><code># execute some commands on the local system
  # access a remote system with an IP address: 10.1.1.1 (for example)
  
  telnet 10.1.1.1
  
  # execute some commands on the remote system
  # log all the activity (in a file) on the Local system
  # exit telnet
  # continue on with executing the rest of the script.
  </code></pre>
  <p>There are 2 problems I am facing here:</p>
  <ol>
  <li><p>How to execute the commands on the remote system from the script (without human interaction)?</p>
  <p>From my experience with some test codes, I was able to deduce that when the <code>telnet 10.1.1.1</code> is executed, telnet goes into an interactive session and the subsequent lines of code in the script are executed on the local system. How can I run the lines of code on the remote system rather than the local one?</p>
  </li>
  <li><p>I am unable to get a log file for the activity in the <code>telnet</code> session on the local system. The stdout redirect I used makes a copy on the remote system (I do not want to perform a copy operation to copy the log to the local system). How can I achieve this functionality?</p>
  </li>
  </ol>