Solved

get the output from a remote site via Expect

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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…
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…

705 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

20 Experts available now in Live!

Get 1:1 Help Now