<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to write script for telnet session in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318862#M712136</link>
    <description>I've written some telnet scripts in PERL.&lt;BR /&gt;&lt;BR /&gt;PERL has a telnet module. With it, I can login to my routers, enter commands to the routers to gather statistics. The script looks like this &lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl -w -I/opt/perl/lib/5.6.1/Net&lt;BR /&gt;#&lt;BR /&gt;use Telnet;&lt;BR /&gt;$|=1;&lt;BR /&gt;&lt;BR /&gt;$Vanguard=shift(@ARGV);&lt;BR /&gt;$Password=shift(@ARGV);&lt;BR /&gt;$theVanguard=Net::Telnet-&amp;gt;new(Timeout=&amp;gt;10,Prompt=&amp;gt;'/OK\n/',Host=&amp;gt;$Vanguard)&lt;BR /&gt;    or die("Cannot Connect $Vanguard");&lt;BR /&gt;&lt;BR /&gt;print "Hostname : $Vanguard\n";&lt;BR /&gt;&lt;BR /&gt;#################&lt;BR /&gt;# Wait for OK - then send ATDS to connect&lt;BR /&gt;#################&lt;BR /&gt;$theVanguard-&amp;gt;prompt("/Enter Password:/");&lt;BR /&gt;@listing=$theVanguard-&amp;gt;cmd("atds");&lt;BR /&gt;print "@listing";&lt;BR /&gt;&lt;BR /&gt;###&lt;BR /&gt;#  Enter password and wait for enter selection prompt&lt;BR /&gt;###&lt;BR /&gt;&lt;BR /&gt;$theVanguard-&amp;gt;prompt('/Enter Selection:/');&lt;BR /&gt;@listing=$theVanguard-&amp;gt;cmd($Password) or die ("Wrong Password $Vanguard\n");&lt;BR /&gt;print "@listing";&lt;BR /&gt;&lt;BR /&gt;###&lt;BR /&gt;#  Enter Commands to get statistics&lt;BR /&gt;###&lt;BR /&gt;&lt;BR /&gt;$theVanguard-&amp;gt;prompt('/Enter Selection:/');&lt;BR /&gt;@listing=$theVanguard-&amp;gt;cmd("5");&lt;BR /&gt;print "@listing";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The $theVanguard=Net::Telnet-&amp;gt;new(Timeout=&amp;gt;10,Prompt=&amp;gt;'/OK\n/',Host=&amp;gt;$Vanguard)&lt;BR /&gt;opens the connection to the host($Vanguard which is the first argument passed to the script) and waits for the host to respond with "OK" for up to 10 seconds. If it fails then the die clause is executed.&lt;BR /&gt;&lt;BR /&gt;It sends the password to the host (which is the second argument passed to the script) and waits for up to 10 seconds for the host to respond with "Enter Selection"&lt;BR /&gt;&lt;BR /&gt;When the enter selection is sent, it starts sending commands to the host. The @listing array contains the host's responses to the commands that are printed to stdout. I generally redirect standard out to a file for later review.&lt;BR /&gt;&lt;BR /&gt;PERL Black Book ISBN: 1-57610-465-6 Publiched by  CoriolisOpen Press Written by Steven Holzer is an excellent resource and contains the documentation on using the telnet module.&lt;BR /&gt;&lt;BR /&gt;-Good Luck&lt;BR /&gt;</description>
    <pubDate>Thu, 01 Jul 2004 08:29:13 GMT</pubDate>
    <dc:creator>R. Allan Hicks</dc:creator>
    <dc:date>2004-07-01T08:29:13Z</dc:date>
    <item>
      <title>How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318852#M712126</link>
      <description>Dear all,&lt;BR /&gt;&lt;BR /&gt;I want to write a script ( .sh ) for telnet session and auto login to the system. How to do it ? Please help</description>
      <pubDate>Wed, 30 Jun 2004 03:54:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318852#M712126</guid>
      <dc:creator>Edward Tse</dc:creator>
      <dc:date>2004-06-30T03:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318853#M712127</link>
      <description>search in this forum buddy ... this has been already discussed here&lt;BR /&gt;&lt;BR /&gt;Kaps</description>
      <pubDate>Wed, 30 Jun 2004 04:00:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318853#M712127</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2004-06-30T04:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318854#M712128</link>
      <description>Check this thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=496072" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=496072&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Wed, 30 Jun 2004 04:02:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318854#M712128</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-06-30T04:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318855#M712129</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;have a look at:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=601133" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=601133&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;manish</description>
      <pubDate>Wed, 30 Jun 2004 04:06:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318855#M712129</guid>
      <dc:creator>Manish Srivastava</dc:creator>
      <dc:date>2004-06-30T04:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318856#M712130</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;check this thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=496072" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=496072&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Anyway this was posted more times in ITRC forum, try to insert keywords 'telnet script' in ITRC search.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Ettore</description>
      <pubDate>Wed, 30 Jun 2004 04:17:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318856#M712130</guid>
      <dc:creator>Fabio Ettore</dc:creator>
      <dc:date>2004-06-30T04:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318857#M712131</link>
      <description>It is right?&lt;BR /&gt;&lt;BR /&gt;Script:&lt;BR /&gt;&lt;BR /&gt;Telnet ip-address&lt;BR /&gt;sleep 5&lt;BR /&gt;echo username&lt;BR /&gt;sleep 5&lt;BR /&gt;echo password&lt;BR /&gt;&lt;BR /&gt;I try this, but it isn't work. Please help</description>
      <pubDate>Wed, 30 Jun 2004 04:26:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318857#M712131</guid>
      <dc:creator>Edward Tse</dc:creator>
      <dc:date>2004-06-30T04:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318858#M712132</link>
      <description>There a way to do it this way, check &lt;A href="http://steve-parker.org/sh/expect.shtml" target="_blank"&gt;http://steve-parker.org/sh/expect.shtml&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;But, you'll find that Expect is really what you need, if rsh (or ssh) won't be satisfactory (why ??).&lt;BR /&gt;&lt;BR /&gt;Ant (what make is for C, ant is for Java) has also telnet scripting capabilities).&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Nicolas</description>
      <pubDate>Wed, 30 Jun 2004 05:10:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318858#M712132</guid>
      <dc:creator>Nicolas Dumeige</dc:creator>
      <dc:date>2004-06-30T05:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318859#M712133</link>
      <description>If you are familiar with "perl", you can drive a telnet session with "Net::Telnet" module. Example-&lt;BR /&gt; &lt;BR /&gt;use Net::Telnet ();&lt;BR /&gt;$t = new Net::Telnet (Timeout =&amp;gt; 10,&lt;BR /&gt;Prompt =&amp;gt; '/bash\$ $/');&lt;BR /&gt;$t-&amp;gt;open("sparky");&lt;BR /&gt;$t-&amp;gt;login($username, $passwd);&lt;BR /&gt;@lines = $t-&amp;gt;cmd("/usr/bin/who");&lt;BR /&gt;print @lines;&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Jun 2004 08:47:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318859#M712133</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-06-30T08:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318860#M712134</link>
      <description>Install EXPECT &lt;BR /&gt;&lt;BR /&gt;Download HERE: &lt;BR /&gt;&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.41/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.41/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/expect&lt;BR /&gt;spawn telnet &lt;IP_ADDRESS&gt;&lt;BR /&gt;expect "login"&lt;BR /&gt;send "USERNAME\r"&lt;BR /&gt;expect "Password:"&lt;BR /&gt;send "PASSWORD\r"&lt;BR /&gt;expect "# "&lt;BR /&gt;&lt;BR /&gt;YOU CAN SEND and Expect commands.. &lt;BR /&gt;&lt;BR /&gt;Get the OReilly Book "Expect" &lt;BR /&gt;&lt;BR /&gt;&lt;/IP_ADDRESS&gt;</description>
      <pubDate>Thu, 01 Jul 2004 08:06:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318860#M712134</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2004-07-01T08:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318861#M712135</link>
      <description>Here is the Expect Main Site &lt;BR /&gt;&lt;A href="http://expect.nist.gov/" target="_blank"&gt;http://expect.nist.gov/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2004 08:08:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318861#M712135</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2004-07-01T08:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318862#M712136</link>
      <description>I've written some telnet scripts in PERL.&lt;BR /&gt;&lt;BR /&gt;PERL has a telnet module. With it, I can login to my routers, enter commands to the routers to gather statistics. The script looks like this &lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl -w -I/opt/perl/lib/5.6.1/Net&lt;BR /&gt;#&lt;BR /&gt;use Telnet;&lt;BR /&gt;$|=1;&lt;BR /&gt;&lt;BR /&gt;$Vanguard=shift(@ARGV);&lt;BR /&gt;$Password=shift(@ARGV);&lt;BR /&gt;$theVanguard=Net::Telnet-&amp;gt;new(Timeout=&amp;gt;10,Prompt=&amp;gt;'/OK\n/',Host=&amp;gt;$Vanguard)&lt;BR /&gt;    or die("Cannot Connect $Vanguard");&lt;BR /&gt;&lt;BR /&gt;print "Hostname : $Vanguard\n";&lt;BR /&gt;&lt;BR /&gt;#################&lt;BR /&gt;# Wait for OK - then send ATDS to connect&lt;BR /&gt;#################&lt;BR /&gt;$theVanguard-&amp;gt;prompt("/Enter Password:/");&lt;BR /&gt;@listing=$theVanguard-&amp;gt;cmd("atds");&lt;BR /&gt;print "@listing";&lt;BR /&gt;&lt;BR /&gt;###&lt;BR /&gt;#  Enter password and wait for enter selection prompt&lt;BR /&gt;###&lt;BR /&gt;&lt;BR /&gt;$theVanguard-&amp;gt;prompt('/Enter Selection:/');&lt;BR /&gt;@listing=$theVanguard-&amp;gt;cmd($Password) or die ("Wrong Password $Vanguard\n");&lt;BR /&gt;print "@listing";&lt;BR /&gt;&lt;BR /&gt;###&lt;BR /&gt;#  Enter Commands to get statistics&lt;BR /&gt;###&lt;BR /&gt;&lt;BR /&gt;$theVanguard-&amp;gt;prompt('/Enter Selection:/');&lt;BR /&gt;@listing=$theVanguard-&amp;gt;cmd("5");&lt;BR /&gt;print "@listing";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The $theVanguard=Net::Telnet-&amp;gt;new(Timeout=&amp;gt;10,Prompt=&amp;gt;'/OK\n/',Host=&amp;gt;$Vanguard)&lt;BR /&gt;opens the connection to the host($Vanguard which is the first argument passed to the script) and waits for the host to respond with "OK" for up to 10 seconds. If it fails then the die clause is executed.&lt;BR /&gt;&lt;BR /&gt;It sends the password to the host (which is the second argument passed to the script) and waits for up to 10 seconds for the host to respond with "Enter Selection"&lt;BR /&gt;&lt;BR /&gt;When the enter selection is sent, it starts sending commands to the host. The @listing array contains the host's responses to the commands that are printed to stdout. I generally redirect standard out to a file for later review.&lt;BR /&gt;&lt;BR /&gt;PERL Black Book ISBN: 1-57610-465-6 Publiched by  CoriolisOpen Press Written by Steven Holzer is an excellent resource and contains the documentation on using the telnet module.&lt;BR /&gt;&lt;BR /&gt;-Good Luck&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2004 08:29:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318862#M712136</guid>
      <dc:creator>R. Allan Hicks</dc:creator>
      <dc:date>2004-07-01T08:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to write script for telnet session</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318863#M712137</link>
      <description>I've used both Expect, Perl and KSH and found expect 100 times less cryptic to write these type of things then Perl.. &lt;BR /&gt;&lt;BR /&gt;We are using it for in house OLTP between multiple boxes, inserting records into Informix, Postgres or Mysql databases.. &lt;BR /&gt;&lt;BR /&gt;In addition to automated file transfers.. &lt;BR /&gt;&lt;BR /&gt;I general use perl for in file edits, using perl -pi -e g/&lt;VAR1&gt;/&lt;NEWVAR&gt;/s file and that's about it. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/NEWVAR&gt;&lt;/VAR1&gt;</description>
      <pubDate>Thu, 01 Jul 2004 09:13:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-write-script-for-telnet-session/m-p/3318863#M712137</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2004-07-01T09:13:06Z</dc:date>
    </item>
  </channel>
</rss>

