<?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: Telnet Script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044577#M74104</link>
    <description>If you don't mind having a password in clear text in a file, someone posted this solution.&lt;BR /&gt;&lt;BR /&gt;In a file (name ToDo) put all commands you want to pass in the telnet session.&lt;BR /&gt;&lt;USER&gt;&lt;BR /&gt;&lt;PASSWD&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;EXIT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In an other file "ScriptFile"&lt;BR /&gt;telnet @IP &amp;lt; ToDo&lt;BR /&gt;&lt;BR /&gt;And execute ScriptFile &lt;BR /&gt;&lt;BR /&gt;The password goes across the network clear text, so whats the big deal about having it in an open file.&lt;BR /&gt;&lt;BR /&gt;Openssh would be a better alternative.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;/EXIT&gt;&lt;/PASSWD&gt;&lt;/USER&gt;</description>
    <pubDate>Fri, 08 Aug 2003 01:36:03 GMT</pubDate>
    <dc:creator>Steven E. Protter</dc:creator>
    <dc:date>2003-08-08T01:36:03Z</dc:date>
    <item>
      <title>Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044575#M74102</link>
      <description>I need a way to telnet from a WIN XP machine to a linux machine from somesort of .bat file to run a set amount of commands on the remote linux machine.  Some of the commands do change so I need a file that I can edit easly.&lt;BR /&gt;(Note: the processor one the linux machine is very slow so running any language fancier the C will not work)&lt;BR /&gt;&lt;BR /&gt;Any suggestion are greatly appreciated.</description>
      <pubDate>Thu, 07 Aug 2003 21:35:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044575#M74102</guid>
      <dc:creator>Brian_213</dc:creator>
      <dc:date>2003-08-07T21:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044576#M74103</link>
      <description>get this first.&lt;BR /&gt;&lt;A href="http://expect.nist.gov/#windows" target="_blank"&gt;http://expect.nist.gov/#windows&lt;/A&gt; or&lt;BR /&gt;&lt;A href="http://bmrc.berkeley.edu/people/chaffee/expectnt.html" target="_blank"&gt;http://bmrc.berkeley.edu/people/chaffee/expectnt.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and then use this script&lt;BR /&gt;+++++++++++++++++&lt;BR /&gt;#!/usr/bin/expect -f&lt;BR /&gt;# &lt;BR /&gt;# This script telnets to a specific host as a specifc user and sets the required &lt;BR /&gt;# environment variables.&lt;BR /&gt;&lt;BR /&gt;#Change default timeout&lt;BR /&gt;set timeout 100&lt;BR /&gt;&lt;BR /&gt;#Variables. Change as necessary&lt;BR /&gt;set TERM xterm    ;#default TERM&lt;BR /&gt;set prompt "(%|#|\\$) $"           ;# default prompt&lt;BR /&gt;&lt;BR /&gt;catch {set prompt $env(EXPECT_PROMPT)}&lt;BR /&gt;&lt;BR /&gt;#Host Name&lt;BR /&gt;set SERVER "[lrange $argv 0 0]"&lt;BR /&gt;set USER "[lrange $argv 1 1]"&lt;BR /&gt;set PASSWD "[lrange $argv 2 2]"&lt;BR /&gt;&lt;BR /&gt;#Command List&lt;BR /&gt;set COMMANDS "[lrange $argv 3 $argc]"&lt;BR /&gt;&lt;BR /&gt;#Spawn Telnet&lt;BR /&gt;spawn telnet&lt;BR /&gt;expect  "telnet&amp;gt; "&lt;BR /&gt;&lt;BR /&gt;#Initialise a Connection&lt;BR /&gt;send "open $SERVER\r"&lt;BR /&gt;&lt;BR /&gt;#Login to the Server&lt;BR /&gt;expect {&lt;BR /&gt; -re "Connection timed out" {&lt;BR /&gt;  send_user "Unable to connect to $host. Exiting..."&lt;BR /&gt;  exit 1&lt;BR /&gt;  }&lt;BR /&gt; timeout {&lt;BR /&gt;  send_user "Timed out connecting to $host. Exiting..."&lt;BR /&gt;  exit 1&lt;BR /&gt;  }&lt;BR /&gt; "login* "&lt;BR /&gt; }&lt;BR /&gt;send "$USER\r"&lt;BR /&gt;expect "Password:*"&lt;BR /&gt;send "$PASSWD\r"&lt;BR /&gt;&lt;BR /&gt;expect {&lt;BR /&gt; -re "Login incorrect*" {&lt;BR /&gt;  send_user "Looks like the password is wrong. Spawning a shell..."&lt;BR /&gt;  interact&lt;BR /&gt;  exit 1&lt;BR /&gt; }&lt;BR /&gt; -re $prompt &lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#loop through arguments&lt;BR /&gt;foreach command  $COMMANDS {&lt;BR /&gt;  send "$command\r"&lt;BR /&gt; expect -re $prompt&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;send_user "Expect Scripts Ends. Good Bye!!!\n"&lt;BR /&gt;+++++++++++++++++&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run this script as&lt;BR /&gt;&lt;BR /&gt;scriptname server name password command(s)&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;-balaji</description>
      <pubDate>Thu, 07 Aug 2003 22:40:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044576#M74103</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2003-08-07T22:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044577#M74104</link>
      <description>If you don't mind having a password in clear text in a file, someone posted this solution.&lt;BR /&gt;&lt;BR /&gt;In a file (name ToDo) put all commands you want to pass in the telnet session.&lt;BR /&gt;&lt;USER&gt;&lt;BR /&gt;&lt;PASSWD&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;EXIT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In an other file "ScriptFile"&lt;BR /&gt;telnet @IP &amp;lt; ToDo&lt;BR /&gt;&lt;BR /&gt;And execute ScriptFile &lt;BR /&gt;&lt;BR /&gt;The password goes across the network clear text, so whats the big deal about having it in an open file.&lt;BR /&gt;&lt;BR /&gt;Openssh would be a better alternative.&lt;BR /&gt;&lt;BR /&gt;SEP&lt;/EXIT&gt;&lt;/PASSWD&gt;&lt;/USER&gt;</description>
      <pubDate>Fri, 08 Aug 2003 01:36:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044577#M74104</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-08-08T01:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044578#M74105</link>
      <description>Could you not use ftp from XP the command file (script) and have a crontab job running every so often (that depend on reaction time is critical), let say 5 minutes for example.&lt;BR /&gt;&lt;BR /&gt;You could use sftp from putty on the XP &lt;BR /&gt;this is can be downloaded from many places&lt;BR /&gt;in the Telnet category at Tucows.com. Tucows &lt;BR /&gt;or &lt;A href="http://www.putty.nl/download.html" target="_blank"&gt;http://www.putty.nl/download.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The stting up of the ssh (putty)is not that tedious and once you have your private/public key set up right it would be more secure&lt;BR /&gt;&lt;BR /&gt;hope this track will be of use &lt;BR /&gt;whatever keep us informed.&lt;BR /&gt;&lt;BR /&gt;Jean-Pierre  &lt;BR /&gt;</description>
      <pubDate>Fri, 08 Aug 2003 07:51:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044578#M74105</guid>
      <dc:creator>Huc_1</dc:creator>
      <dc:date>2003-08-08T07:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044579#M74106</link>
      <description>Ok I tried the following command that was suggested above.&lt;BR /&gt;&lt;BR /&gt;telnet 192.168.0.58 &amp;lt; toDo.txt&lt;BR /&gt;&lt;BR /&gt;and all that was returned was&lt;BR /&gt;&lt;BR /&gt;Welcome to Microsoft Telnet Client&lt;BR /&gt;Excape Character is 'CTRL+]'&lt;BR /&gt;&lt;BR /&gt;Yet when I go telnet 192.168.0.58 I got the login prompt from my linux machine.  I did have the 'telnet 192.168.0.68 &amp;lt; toDo.txt' originally in a .bat file but when nothing happend I tried typing it into the command prompt manually instead.&lt;BR /&gt;&lt;BR /&gt;Any suggestions are greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 11 Aug 2003 14:19:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044579#M74106</guid>
      <dc:creator>Brian_213</dc:creator>
      <dc:date>2003-08-11T14:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044580#M74107</link>
      <description>I would use Perl, but that's me. You can install activeperl or cygwin. If you need help contact me.</description>
      <pubDate>Thu, 21 Aug 2003 10:40:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044580#M74107</guid>
      <dc:creator>Joost_4</dc:creator>
      <dc:date>2003-08-21T10:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044581#M74108</link>
      <description>&lt;BR /&gt;If you ty to redirect its stdin or stdout, it will not work, it will die. That's how telnet works :(&lt;BR /&gt;&lt;BR /&gt;BUT, take a look at:&lt;BR /&gt;Telnet Scripting Tool v.1.0&lt;BR /&gt;by Albert Yale ay@aci.qc.ca &lt;A href="http://ay.home.ml.org/" target="_blank"&gt;http://ay.home.ml.org/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I think that homepage is not functional anymore, but it can be found literally anywhere on the Net (try Google, you find it).&lt;BR /&gt;&lt;BR /&gt;It lets you write a very, very, very simple script, in which you put commands to be executed on the remote system, and stores output in a text file. After it sends a command, it waits for a specified answer, so the speed of the remote system is not relevant.&lt;BR /&gt;&lt;BR /&gt;Can be envoked from .BAT, and Windows Scripting Host Files (.VBs, .JS)</description>
      <pubDate>Thu, 11 Sep 2003 09:55:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044581#M74108</guid>
      <dc:creator>ziggy_starlight</dc:creator>
      <dc:date>2003-09-11T09:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044582#M74109</link>
      <description>I'm trying to do that in bash script, but I'm stopping at the same problem. How to send a password to a telnet login prompt?&lt;BR /&gt;&lt;BR /&gt;:) gustavo</description>
      <pubDate>Tue, 23 Sep 2003 20:21:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044582#M74109</guid>
      <dc:creator>Gustavo Feijo</dc:creator>
      <dc:date>2003-09-23T20:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Telnet Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044583#M74110</link>
      <description>Actually, you can do some nasty echo, sleep's to get that to work. NOTE: I do not suggest you use this, but this is how it can work:&lt;BR /&gt; &lt;BR /&gt;(&lt;BR /&gt; sleep 3 # This is to wait for the connection to occur&lt;BR /&gt; echo username&lt;BR /&gt; sleep 2 # Username will go in Login: prompt, this will wait a while for Passwrod:&lt;BR /&gt; echo password&lt;BR /&gt; sleep 2 # finish the login, get a prompt&lt;BR /&gt; echo "CommandToExecute; exit"&lt;BR /&gt; sleep XX # wait for command to complete, then exit.&lt;BR /&gt;) | telnet HOST&lt;BR /&gt; &lt;BR /&gt;Now, whilst this will work in simple situations, it doesn't have any accountability with regards to network degredation, or server load.  Using Expect takes these into consideration, simply by waiting for expected text.&lt;BR /&gt; &lt;BR /&gt;The above example just takes 'guesses', in other words *IS NOT RELIABLE!*.</description>
      <pubDate>Tue, 23 Sep 2003 21:01:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/telnet-script/m-p/3044583#M74110</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2003-09-23T21:01:42Z</dc:date>
    </item>
  </channel>
</rss>

