Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 885
  • Last Modified:

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?


0
cw1592
Asked:
cw1592
  • 2
1 Solution
 
shanikawmCommented:
expect command return an array. So  you try and see,


$exp->send("ls\n");
my @ls=$exp->expect(20);
print join("\n",@ls),"\n";

Open in new window

0
 
cw1592Author Commented:
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?
0
 
Adam314Commented:
post all of your code, and we can take a look
0
 
cw1592Author Commented:
I guess the code from shanikawm is working, it is just the format looks different from I expected. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now