Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Issue with capture the output of android command in perl

by ramki067 (Acolyte)
on Nov 27, 2013 at 08:27 UTC ( #1064576=perlquestion: print w/replies, xml ) Need Help??
ramki067 has asked for the wisdom of the Perl Monks concerning the following question:

I'm running a perl script on android prompt. Wanted to know how do i capture output of a android command to a perl variable. I've done the following, but output is not captured. Please help.
use Net::Telnet; $ip=''; $ip_port='10009'; $port = Net::Telnet->new( Host=>$ip,Port=>$ip_port,Dump_log=> "dump.l +og"); @lnes= $port->cmd("input keyevent 66"); sleep(5); $lc=0; print "Console Log:"; while($lc<5) { print $lnes[$lc]; print FILE $lnes[$lc]; ++$lc; }
I"m getting only "root@android:/mnt/sdcard # input keyevent 66" only and not the messages displayed after i enter this command. Please help.

Replies are listed 'Best First'.
Re: Issue with capture the output of android command in perl
by shmem (Canon) on Nov 27, 2013 at 09:27 UTC

    At the moment the list of lines is assigned to your @lnes variable (why do you omit the i? iShortage?), the telnet command already has returned. No need to sleep here.

    The problem might be that a) there are no lines returned or b) the lines are empty and/or c) they have no newline character at the end. Try:

    @lines= $port->cmd("input keyevent 66"); # added i print "Number of lines returned: ", scalar(@lines), "\n"; print "Console Log:\n"; # added newline character for( @lines ) { print ">$_<\n" }
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1064576]
Approved by Corion
[stevieb]: it is exceptionally difficult I'm finding to debug a dist that is x-platform, where on each platform you're wrapping a different binary. Trying to co-ordinate a successful test run where tests are extensive is a nightmare, especially when the dist...
[stevieb]:'re testing is a test system itself. 10+ documented issues fixed, another half dozen found while fixing the original ones. I'm getting there...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-03-28 21:56 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (342 votes). Check out past polls.