Or if you don&#39;t have netcat or expect install, you could always do something like:<br><br>#!/bin/bash<br>( echo jump mythgallery;<br>&nbsp; echo exit;<br>) | telnet $hostname 6546<br>exit 0;<br><br>&nbsp;--Matt<br><br><div class="gmail_quote">
On Jan 22, 2008 7:18 PM, Florin Andrei &lt;<a href="mailto:florin@andrei.myip.org">florin@andrei.myip.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Steve Peters - Priority Electronics wrote:<br></div><div class="Ih2E3d">&gt; ------------------------------------------<br>&gt; #!/bin/bash<br>&gt; telnet mythtv-frontend 6546<br>&gt; jump mythgallery<br>
&gt; exit<br>&gt; exit 0<br>&gt; ------------------------------------------<br>&gt; The idea with that above script is that it just changes my mythfrontend<br>&gt; to open the gallery then exit telnet and then exit the script...it
<br>&gt; didn&#39;t work.<br><br></div>What you&#39;re looking for is a package called expect. It comes with all<br>Linux distros I&#39;m aware of. It can be used to record and &quot;play back&quot; any<br>interactive session - telnet, ftp, ssh, you name it. The recording part
<br>is done by a utility called autoexpect, which creates a .exp script.<br>Then you just replay the .exp script with expect.<br><br>For some weird reason, in Ubuntu autoexpect is part of the expect-dev<br>package, and even then it&#39;s not in the $PATH, but it&#39;s in
<br>/usr/share/doc/expect-dev/examples/autoexpect.gz - somebody was smoking<br>a lot of bad stuff when they put together the package.<br>On Fedora / Red Hat / CentOS autoexpect is part of the normal expect<br>package and is in $PATH.
<br><br>After you generate the .exp script, feel free to edit the &quot;expect&quot;<br>statements, especially if they&#39;re &quot;expect -exact&quot; - usually you only<br>need the tail end of the whole string - e.g. do not expect for 25 lines
<br>of output, but only for the return of the prompt at the end.<br>That&#39;s the only bit of advice that you really need with autoexpect.<br><br><br><br>Here&#39;s a .exp file that records &quot;telnet <a href="http://google.com" target="_blank">
google.com</a> 80&quot;:<br><br>#!/usr/bin/expect -f<br>#<br># This Expect script was generated by autoexpect on Tue Jan 22 16:09:33 2008<br># Expect and autoexpect were both written by Don Libes, NIST.<br>#<br># Note that autoexpect does not guarantee a working script. &nbsp;It
<br># necessarily has to guess about certain things. &nbsp;Two reasons a script<br># might fail are:<br>#<br># 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,<br># etc.) and devices discard or ignore keystrokes that arrive &quot;too
<br># quickly&quot; after prompts. &nbsp;If you find your new script hanging up at<br># one spot, try adding a short sleep just before the previous send.<br># Setting &quot;force_conservative&quot; to 1 (see below) makes Expect do this
<br># automatically - pausing briefly before sending each character. &nbsp;This<br># pacifies every program I know of. &nbsp;The -c flag makes the script do<br># this in the first place. &nbsp;The -C flag allows you to define a<br># character to toggle this mode off and on.
<br><br>set force_conservative 0 &nbsp;;# set to 1 to force conservative mode even if<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;# script wasn&#39;t run conservatively originally<br>if {$force_conservative} {<br> &nbsp; &nbsp; &nbsp; &nbsp; set send_slow {1 .1}
<br> &nbsp; &nbsp; &nbsp; &nbsp; proc send {ignore arg} {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep .1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exp_send -s -- $arg<br> &nbsp; &nbsp; &nbsp; &nbsp; }<br>}<br><br>#<br># 2) differing output - Some programs produce different output each time<br># they run. &nbsp;The &quot;date&quot; command is an obvious example. &nbsp;Another is
<br># ftp, if it produces throughput statistics at the end of a file<br># transfer. &nbsp;If this causes a problem, delete these patterns or replace<br># them with wildcards. &nbsp;An alternative is to use the -p flag (for<br># &quot;prompt&quot;) which makes Expect only look for the last line of output
<br># (i.e., the prompt). &nbsp;The -P flag allows you to define a character to<br># toggle this mode off and on.<br>#<br># Read the man page for more info.<br>#<br># -Don<br><br><br>set timeout -1<br>spawn $env(SHELL)<br>match_max 100000
<br>expect -exact &quot;]0;florin@scout: ~florin@scout:~\$ &quot;<br>send -- &quot;telnet <a href="http://google.com" target="_blank">google.com</a> 80\r&quot;<br>expect -exact &quot;telnet <a href="http://google.com" target="_blank">
google.com</a> 80\r<br>Trying 64.233.167.99...\r<br>Connected to google.com.\r<br>Escape character is &#39;^\]&#39;.\r<br>&quot;<br>send -- &quot;HEAD / HTTP/1.1\r&quot;<br>expect -exact &quot;HEAD / HTTP/1.1\r<br>&quot;<br>
send -- &quot;\r&quot;<br>expect -exact &quot;\r<br>HTTP/1.1 200 OK\r<br>Cache-Control: private\r<br>Content-Type: text/html; charset=ISO-8859-1\r<br>Set-Cookie:<br>PREF=ID=fd69576a5e09d550:TM=1201046993:LM=1201046993:S=p1NDq1JyrFXzBvh-;
<br>expires=Fri, 22-Jan-2010 00:09:53 GMT; path=/; domain=.google.com\r<br>Server: gws\r<br>Content-Length: 0\r<br>Date: Wed, 23 Jan 2008 00:09:53 GMT\r<br>\r<br>&quot;<br>send -- &quot; &quot;<br>expect -exact &quot;^\]\r
<br>telnet&gt; &quot;<br>send -- &quot;QUIT\r&quot;<br>expect -exact &quot;QUIT\r<br>Connection closed.\r<br>]0;florin@scout: ~florin@scout:~\$ &quot;<br>send -- &quot;exit\r&quot;<br>expect eof<br><font color="#888888"><br>
<br>--<br>Florin Andrei<br><br><a href="http://florin.myip.org/" target="_blank">http://florin.myip.org/</a><br></font><div><div></div><div class="Wj3C7c">_______________________________________________<br>mythtv-users mailing list
<br><a href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a><br><a href="http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users" target="_blank">http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users</a><br>
</div></div></blockquote></div><br>