title: Telnet inside a shell script
body: <p>How can I run telnet inside a shell script and execute commands on the remote server?</p>
  
  <p>I do not have expect installed on my solaris machine because of security reasons.
  I also do not have the perl <code>net::telnet</code> module installed.</p>
  
  <p>So with out using expect and perl how can I do it?</p>
  
  <p>I tried the below thing but its not working.</p>
  
  <pre><code>#!/usr/bin/sh
  telnet 172.16.69.116 &lt;&lt;!
  user
  password
  ls
  exit
  !
  </code></pre>
  
  <p>When I execute it, this is what I am getting:</p>
  
  <pre><code>&gt; cat tel.sh
  telnet 172.16.69.116 &lt;&lt;EOF
  xxxxxx
  xxxxxxxxx
  ls
  exit
  EOF
  &gt; tel.sh
  Trying 172.16.69.116...
  Connected to 172.16.69.116.
  Escape character is '^]'.
  Connection to 172.16.69.116 closed by foreign host.
  &gt; 
  </code></pre>