<?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: Telneting within a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711785#M60769</link>
    <description>I agree with Frank, expect is usually the way to go with telnet and ftp connections in scripts. I personally would look at setting up secure shell trusts, thus protecting your password from running in the clear and negating the use of expect.&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
    <pubDate>Fri, 26 Apr 2002 12:43:33 GMT</pubDate>
    <dc:creator>Craig Rants</dc:creator>
    <dc:date>2002-04-26T12:43:33Z</dc:date>
    <item>
      <title>Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711777#M60761</link>
      <description>I have a script to telnet from one server to another...looks something like this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;REMOTE=server2  &lt;BR /&gt;(sleep 1&lt;BR /&gt;echo username&lt;BR /&gt;sleep 2&lt;BR /&gt;echo password) | telnet $REMOTE&lt;BR /&gt;&lt;BR /&gt;It works between some servers but not all and when it fails it kicks you out with the message " Connection closed by foreign host." &lt;BR /&gt;&lt;BR /&gt;You can telnet normally between the servers but for some reason it doesn't like my script. Anyone know of any settings that might be preventing this??&lt;BR /&gt;&lt;BR /&gt;Thanks Barbara.</description>
      <pubDate>Fri, 26 Apr 2002 09:06:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711777#M60761</guid>
      <dc:creator>Philip Lunney</dc:creator>
      <dc:date>2002-04-26T09:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711778#M60762</link>
      <description>Just a shot in the dark, but try increasing the sleep period. Maybe it takes a little longer for some machines to prompt for the username / password.&lt;BR /&gt;And consider using Expect. Quite a handy tool for such stuff.</description>
      <pubDate>Fri, 26 Apr 2002 09:11:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711778#M60762</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-04-26T09:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711779#M60763</link>
      <description>Deepak&lt;BR /&gt;&lt;BR /&gt;Thanks but I tried increasing the sleep but it doesn't even seem to get as far as the password, it returns the connection closed straight away! Any other ideas?&lt;BR /&gt;&lt;BR /&gt;Also what is Expect??</description>
      <pubDate>Fri, 26 Apr 2002 09:16:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711779#M60763</guid>
      <dc:creator>Philip Lunney</dc:creator>
      <dc:date>2002-04-26T09:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711780#M60764</link>
      <description>hi,&lt;BR /&gt;i think the problem is with carriage return &lt;BR /&gt;try putting ; at the end of all your script&lt;BR /&gt;shell commands.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;U.SivaKumar&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Apr 2002 09:20:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711780#M60764</guid>
      <dc:creator>U.SivaKumar_2</dc:creator>
      <dc:date>2002-04-26T09:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711781#M60765</link>
      <description>HI&lt;BR /&gt;&lt;BR /&gt;Run it&lt;BR /&gt;&lt;BR /&gt;ksh -x ./&amp;lt;script name&amp;gt;&lt;BR /&gt;&lt;BR /&gt;and watch it run, it may give you and indication as to where the problem is.&lt;BR /&gt;&lt;BR /&gt;Paula</description>
      <pubDate>Fri, 26 Apr 2002 09:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711781#M60765</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-04-26T09:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711782#M60766</link>
      <description>Barbara,&lt;BR /&gt;&lt;BR /&gt;See &lt;A href="http://expect.nist.gov/" target="_blank"&gt;http://expect.nist.gov/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Does the account get locked after a few failed logins attempts, by any chance?</description>
      <pubDate>Fri, 26 Apr 2002 09:31:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711782#M60766</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-04-26T09:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711783#M60767</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I found that this works with HPUX (at least 10.20 and 11.00) but i.e. not with a linux telnet.&lt;BR /&gt;&lt;BR /&gt;Obviously it depends on the security thinking of the programmer. Now linux guys are hardliners in this case, so I found in linux programs that they flush the input stream before they ask for a password (to avoid, that you mistype something and the password appears in cleartext on the screen). &lt;BR /&gt;&lt;BR /&gt;Such a program will never be able to be scripted in this way, because the entire pipe stream is flushed. HP-UX is more tolerant with this, but I do not know if this has been changed in 11.11 or so.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Volker</description>
      <pubDate>Fri, 26 Apr 2002 09:42:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711783#M60767</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2002-04-26T09:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711784#M60768</link>
      <description>The problem is (non) handshaking/timing. I.e. normally when you use telnet interactively, you *wait* for a certain prompt/reaction and *then* give the next command. In a script that does not happen, because the script does not wait. You can *try* to workaround that with sleeps, but, *if* it works at all, such scripts will fail at some time, often with obscure results. I have had such scripts which failed *years* after working 'correctly'.&lt;BR /&gt;&lt;BR /&gt;The solution is the mentioned "expect" program, which was especially designed for problems like this.</description>
      <pubDate>Fri, 26 Apr 2002 12:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711784#M60768</guid>
      <dc:creator>Frank Slootweg</dc:creator>
      <dc:date>2002-04-26T12:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711785#M60769</link>
      <description>I agree with Frank, expect is usually the way to go with telnet and ftp connections in scripts. I personally would look at setting up secure shell trusts, thus protecting your password from running in the clear and negating the use of expect.&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Fri, 26 Apr 2002 12:43:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711785#M60769</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-04-26T12:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711786#M60770</link>
      <description>I don't do this in the shell anymore at all. Instead I use the Perl Net::Telnet which is available from &lt;A href="http://www.perl.org/CPAN." target="_blank"&gt;www.perl.org/CPAN.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Here is a simple example extracted from the man pages:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    use Net::Telnet ();&lt;BR /&gt;    my $username = "Clay";&lt;BR /&gt;    my $passwd = "TOPSECRET";&lt;BR /&gt;    my $remote_host = "bugs";&lt;BR /&gt;    $t = new Net::Telnet (Timeout =&amp;gt; 30,&lt;BR /&gt;                          Prompt =&amp;gt; '/sh\$ $/');&lt;BR /&gt;    $t-&amp;gt;open($remote_host);&lt;BR /&gt;    $t-&amp;gt;login($username,$passwd);&lt;BR /&gt;    @lines = $t-&amp;gt;cmd("/usr/bin/ls -l /etc");&lt;BR /&gt;    print @lines;&lt;BR /&gt;&lt;BR /&gt;The beauty of this method is that it becomes trivially easy to add error checking.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Apr 2002 13:27:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711786#M60770</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-26T13:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711787#M60771</link>
      <description>the problem is telnet is designed to want a tty on the originating end of the connection. You can try wrapping this around your script:&lt;BR /&gt;&lt;BR /&gt;mknod pipe p&lt;BR /&gt;executable_file &amp;lt; pipe | telnet nnn.nnn.nnn.nnn &amp;gt; pipe 2&amp;gt;telnet.log&lt;BR /&gt;rm pipe&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;mark</description>
      <pubDate>Fri, 26 Apr 2002 15:30:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711787#M60771</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2002-04-26T15:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711788#M60772</link>
      <description>This is from a script that I use to talk to a 3Com switch.  I don't need the \r to talk to a Cisco router but the 3Com seems to require the \r after each line in order to work.  You also may need a little extra sleep time at the beginning to make sure the connection is up before you try to logon.  The first empty echo is required by the 3Com to wake it up.&lt;BR /&gt;&lt;BR /&gt;(sleep 5&lt;BR /&gt;echo "\r"&lt;BR /&gt;sleep 1&lt;BR /&gt;echo "login\r"&lt;BR /&gt;sleep 1&lt;BR /&gt;echo "password\r"&lt;BR /&gt;sleep 2&lt;BR /&gt;echo "\r") |telnet $REMOTE &lt;BR /&gt;&lt;BR /&gt;Ron  &lt;BR /&gt;</description>
      <pubDate>Fri, 26 Apr 2002 19:23:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711788#M60772</guid>
      <dc:creator>Ron Kinner</dc:creator>
      <dc:date>2002-04-26T19:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711789#M60773</link>
      <description>Try,&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh &lt;BR /&gt;REMOTE=server2 &lt;BR /&gt;(sleep 1&lt;BR /&gt;echo username&lt;BR /&gt;sleep 2 &lt;BR /&gt;echo password&lt;BR /&gt;sleep 5) | telnet $REMOTE &lt;BR /&gt;&lt;BR /&gt;Your subshell was ending and dropping the telnet connection.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;&lt;BR /&gt;rhino</description>
      <pubDate>Tue, 30 Apr 2002 15:11:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711789#M60773</guid>
      <dc:creator>Ryan Moore</dc:creator>
      <dc:date>2002-04-30T15:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711790#M60774</link>
      <description>I like my old shell trick... it doesn't require any sleeps at all:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;telnet $server &amp;lt;</description>
      <pubDate>Tue, 30 Apr 2002 16:00:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711790#M60774</guid>
      <dc:creator>Vincent Fleming</dc:creator>
      <dc:date>2002-04-30T16:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Telneting within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711791#M60775</link>
      <description>I tried this on Solaris 8 in bourne shell and Linux 7.0 with bash and bourne shell and this does not work for me.&lt;BR /&gt;&lt;BR /&gt;What system and shell did you use to make this work?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;rhino</description>
      <pubDate>Tue, 30 Apr 2002 19:54:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/telneting-within-a-script/m-p/2711791#M60775</guid>
      <dc:creator>Ryan Moore</dc:creator>
      <dc:date>2002-04-30T19:54:45Z</dc:date>
    </item>
  </channel>
</rss>

