I&#39;m getting closer.. the Expect.pm module does support regular expressions in the from of placing a &#39;-re&#39;,&quot;what I&#39;m trying to match*&quot;); but $match still only has the portion of what is matched up to the &quot;*&quot;; the rest seems tossed by the regular expression match.  I also can&#39;t seem to find the magic variable that contains the full previous line returned.. if I can find that I can use it but it doesn&#39;t appear to be anywhere that I can locate (i.e. $_ or @_ which was, I admit, just a wild guess).<div>
<br><div class="gmail_quote">On Wed, Jan 20, 2010 at 2:35 PM, Greg Brown <span dir="ltr">&lt;<a href="mailto:gwbrown1@gmail.com">gwbrown1@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
First and foremost, I need to get this script finished and I don&#39;t have time to learn Python but it&#39;s on the to-do list.<div><br></div><div>Ok, that said I&#39;m ssh&#39;ing to a remote server (an IDS sensor, really) and I&#39;m trying to read back prompts.  Trouble is when you run a setup command the prompt is going to change each time.  Here&#39;s an example of what I&#39;m dealing with:</div>

<div><br></div><div>#!/usr/bin/perl</div><div><br></div><div>use Expect;</div><div><br></div><div>$ssh = Expect-&gt;spawn(&quot;ssh -l greg myserver&quot;);</div><div><br></div><div># wait for the prompt</div><div>my($which, $why, $match, $before, $after) = $ssh-&gt;expect(30,&quot;assword:)&quot;;</div>

<div><br></div><div># send the password</div><div>print $ssh &quot;myPassword\r&quot;;</div><div><br></div><div># now here&#39;s where we run into problems, the prompt is going to change dynamically and there is no way I can change that</div>

<div>my($which, $why, $match, $before, $after) = $ssh-&gt;expect(30,&quot;:&quot;);</div><div><br></div><div>And there is where I run into problems.. the prompt for each system I ssh to will change dynamically and I want to capture the entire prompt but the $match variable only catches what it matches, not the entire line so $match would equal &quot;:&quot; not &quot;gregtest(192.168.15.99):&quot; and I want to be able to capture that IP address.</div>

<div><br></div><div>What I can&#39;t seem to get working is a way to put a regular expression inside what I want to match, i.e. I can&#39;t seem to say:</div><div><br></div><div>my($which, $why, $match, $before, $after) = $ssh-&gt;expect(30,&quot;greg*:&quot;);</div>

<div><br></div><div>That doesn&#39;t work.</div><div><br></div><div>Any ideas?  I&#39;d really like to get this working.</div><div><br></div><div>Back to <a href="http://google.com" target="_blank">google.com</a></div>
</blockquote></div><br></div>