Solved

get the output from a remote site via Expect

Posted on 2008-10-15
4
875 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now