Solved

get the output from a remote site via Expect

Posted on 2008-10-15
4
879 Views
Last Modified: 2013-11-13
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
Comment
Question by:cw1592
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
shanikawm earned 250 total points
ID: 22729489
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
 

Author Comment

by:cw1592
ID: 22732614
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
 
LVL 39

Expert Comment

by:Adam314
ID: 22733758
post all of your code, and we can take a look
0
 

Author Comment

by:cw1592
ID: 22734194
I guess the code from shanikawm is working, it is just the format looks different from I expected. Thanks.
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question