<?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 send commands to some ports using script? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546396#M17684</link>
    <description>The reason why the 'here-document' didn't work as an input into telnet is because it doesn't wait.&lt;BR /&gt;&lt;BR /&gt;To use a pipe and telnet, you have to force sleeps in to wait for the output, i.e.:&lt;BR /&gt;&lt;BR /&gt;(&lt;BR /&gt;echo ^A&lt;BR /&gt;sleep 1&lt;BR /&gt;echo brk&lt;BR /&gt;sleep 1&lt;BR /&gt;echo chkstatus&lt;BR /&gt;sleep 1&lt;BR /&gt;) | telnet 192.168.10.10 4006&lt;BR /&gt;&lt;BR /&gt;But the better option would be to use 'expect', if there is some sort of output expected after each command.</description>
    <pubDate>Tue, 17 May 2005 17:53:41 GMT</pubDate>
    <dc:creator>Stuart Browne</dc:creator>
    <dc:date>2005-05-17T17:53:41Z</dc:date>
    <item>
      <title>How to send commands to some ports using script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546394#M17682</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to telnet to a Unix box  using some ports. And send some commands.&lt;BR /&gt;Eg :&lt;BR /&gt; telnet &lt;IP addr=""&gt;  &lt;PORT&gt;&lt;BR /&gt;send  ctrl+A&lt;BR /&gt;Now I will get a prompt.&lt;BR /&gt;&lt;BR /&gt;Now send some commends.&lt;BR /&gt;&lt;BR /&gt;send brk&lt;BR /&gt;send chkstatus&lt;BR /&gt;&lt;BR /&gt;I tried  using label . It didn't work. &lt;BR /&gt;&lt;BR /&gt;    e.g. :  telnet 192.168.10.10   4006  &amp;lt;&lt;LABEL&gt;    ^A&lt;BR /&gt;    brk&lt;BR /&gt;    chkstatus&lt;BR /&gt;    LABEL&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;How can I send control+A and some commands .  can some one throw some light on this?&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;&lt;BR /&gt;&lt;/LABEL&gt;&lt;/PORT&gt;&lt;/IP&gt;</description>
      <pubDate>Tue, 17 May 2005 11:19:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546394#M17682</guid>
      <dc:creator>Shashikiran_1</dc:creator>
      <dc:date>2005-05-17T11:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to send commands to some ports using script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546395#M17683</link>
      <description>I would use netcat and perl to do this, something like this:&lt;BR /&gt;&lt;BR /&gt;perl -e 'print \cA' |nc &lt;HOSTNAME&gt; &lt;PORT&gt;&lt;BR /&gt;&lt;BR /&gt;I can't remember if thats the right syntax for ctrl+A, you may have to change that to the decimal equivalent, I think its 001?&lt;BR /&gt;&lt;BR /&gt;--Dave&lt;/PORT&gt;&lt;/HOSTNAME&gt;</description>
      <pubDate>Tue, 17 May 2005 14:31:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546395#M17683</guid>
      <dc:creator>Dave Falloon</dc:creator>
      <dc:date>2005-05-17T14:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to send commands to some ports using script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546396#M17684</link>
      <description>The reason why the 'here-document' didn't work as an input into telnet is because it doesn't wait.&lt;BR /&gt;&lt;BR /&gt;To use a pipe and telnet, you have to force sleeps in to wait for the output, i.e.:&lt;BR /&gt;&lt;BR /&gt;(&lt;BR /&gt;echo ^A&lt;BR /&gt;sleep 1&lt;BR /&gt;echo brk&lt;BR /&gt;sleep 1&lt;BR /&gt;echo chkstatus&lt;BR /&gt;sleep 1&lt;BR /&gt;) | telnet 192.168.10.10 4006&lt;BR /&gt;&lt;BR /&gt;But the better option would be to use 'expect', if there is some sort of output expected after each command.</description>
      <pubDate>Tue, 17 May 2005 17:53:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546396#M17684</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2005-05-17T17:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to send commands to some ports using script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546397#M17685</link>
      <description>&lt;BR /&gt;'expect' is the right method to use for this. &lt;BR /&gt;check man expect to find out how to achieve this.&lt;BR /&gt;&lt;BR /&gt;you can also do through pipe like this,&lt;BR /&gt;&lt;BR /&gt;mkfifo pipe # this will create the pipe&lt;BR /&gt;cat &amp;gt; pipe # this will open the pipe and wait for input, then go to another session&lt;BR /&gt;&lt;BR /&gt;telnet host &amp;lt; pipe # this will open telnet session with input from pipe&lt;BR /&gt;&lt;BR /&gt;now whatever sent in pipe will be piped to telnet. you can use this method to control it from script.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Gopi&lt;BR /&gt;</description>
      <pubDate>Wed, 18 May 2005 01:15:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546397#M17685</guid>
      <dc:creator>Gopi Sekar</dc:creator>
      <dc:date>2005-05-18T01:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to send commands to some ports using script?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546398#M17686</link>
      <description>I played with this a little more, here is another useful way to do this.&lt;BR /&gt;&lt;BR /&gt;printf \\001\\nbrk\\nchkstatus|nc 192.168.10.10 4006&lt;BR /&gt;&lt;BR /&gt;the nice thing about netcat is you don't have to wait for responses, that is built in to the program.&lt;BR /&gt;&lt;BR /&gt;check out the man page for more info:&lt;BR /&gt;&lt;BR /&gt;man nc&lt;BR /&gt;&lt;BR /&gt;--Dave</description>
      <pubDate>Wed, 18 May 2005 13:04:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-send-commands-to-some-ports-using-script/m-p/3546398#M17686</guid>
      <dc:creator>Dave Falloon</dc:creator>
      <dc:date>2005-05-18T13:04:39Z</dc:date>
    </item>
  </channel>
</rss>

