Link to home
Start Free TrialLog in
Avatar of cw1592
cw1592

asked on

get the output from a remote site via Expect

I need to get the output from a Exepct send command and then process the output, but couldn't find a good way to do it.
More precisely, I have:
==============================
$exp->send("ls\n");
my $ls = $exp->expect(20);

for (split /\n/, $ls ){
print "$_";
 }
===========================
It seems to me that the $ls contains no entry at all; help, anyone?


ASKER CERTIFIED SOLUTION
Avatar of shanikawm
shanikawm
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cw1592
cw1592

ASKER

shanikawm,
I run the code and still see anything.

btw, I didn't mention that the $exp is using the sftp; not sure this will make thing different. is the output from ls (via Expect) going into tty? or std out?
post all of your code, and we can take a look
Avatar of cw1592

ASKER

I guess the code from shanikawm is working, it is just the format looks different from I expected. Thanks.