First and foremost, I need to get this script finished and I don't have time to learn Python but it's on the to-do list.<div><br></div><div>Ok, that said I'm ssh'ing to a remote server (an IDS sensor, really) and I'm trying to read back prompts. Trouble is when you run a setup command the prompt is going to change each time. Here's an example of what I'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->spawn("ssh -l greg myserver");</div><div><br></div><div># wait for the prompt</div><div>my($which, $why, $match, $before, $after) = $ssh->expect(30,"assword:)";</div>
<div><br></div><div># send the password</div><div>print $ssh "myPassword\r";</div><div><br></div><div># now here'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->expect(30,":");</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 ":" not "gregtest(192.168.15.99):" and I want to be able to capture that IP address.</div>
<div><br></div><div>What I can't seem to get working is a way to put a regular expression inside what I want to match, i.e. I can't seem to say:</div><div><br></div><div>my($which, $why, $match, $before, $after) = $ssh->expect(30,"greg*:");</div>
<div><br></div><div>That doesn't work.</div><div><br></div><div>Any ideas? I'd really like to get this working.</div><div><br></div><div>Back to <a href="http://google.com">google.com</a></div>