I'm putting together a script which should take a users password, and the option of linux or hpux. Then go out to a collection of computers (Either HP or Linux) find one that isn't being used and start some software for the user on it.
At the moment I am able to connect to another computer using expect with an ssh command:
$timeout = 1;
$command = '/usr/bin/ssh';
@paramaters = ('servername','pwd');
$exp = Expect->spawn($command, @paramaters)
or die "Cannot spawn $command: $!\n";
$exp->expect($timeout, [ qr/password/ ]);
$exp->send("password\n");
$exp->soft_close();
This will nicely go through all the steps that I want it to. However I have yet to figure out how to collect data from this effort (In this case the output of 'pwd'). I've tried things like:
$output = $exp->exp_after();
# and
$output = $exp->expect($timeout, [ qr/password/ ]);
# and
$output = $exp->send("password\n");
none of these however seem to put anything into $output
The reason that I want to collect output is to test it to see if the software is running on the system (If it is, it is considered used.)
ssh (the perl module) isn't too viable, as I would need to get it installed on an HPUX system. And I would prefer to avoid that world of excitment for the moment. But who knows.
ssh keys are less viable, as a bunch of random people will be using the script.
Well thank you for any help.
Michael
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.