[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

get the output from a remote site via Expect

Posted on 2008-10-15
4
Medium Priority
?
882 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 750 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Make the most of your online learning experience.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

656 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