Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to invoke external progrmme and capture its output

Status
Not open for further replies.

korcanUcar

Programmer
Aug 3, 2012
1
TR
Hi all,
I am using an external binary to view memory starting from a specific address and i want to automate this via perl however there are problems. Hope you can help me ..thx

The output of the programme is like below:

bash-3.2$ mem_disp 12B21D20 100
Opening RO Data Memory File scp.ro
Opening Memory File CP2.16.0000000c.18.pmd.raw
12B21D20 12B6E500 186CAF00 12D81A00 00000010 *.....l..........*
12B21D30 000000AA 01060009 00000088 00000000 *................*
12B21D40 F05500FF 00019E02 00030000 00047849 *.U............xI*
12B21D50 0001013F 0001012F 805A0022 00593FC1 *...?.../.Z.".Y?.*
12B21D60 A5020000 480E05ED 00010000 00900058 *....H..........X*
12B21D70 00000000 00000000 00000000 00000000 *................*
12B21D80 43616C6C 50726F63 00000000 00000000 *CallProc........*
12B21D90 00000000 00000000 43616C6C 50726F63 *........CallProc*
12B21DA0 5F537663 5F534259 00000000 00000000 *_Svc_SBY........*

I have around 30K of addresses which i want to send each to the programme above and split & save in a seperate log file ..i firstly tried to verify that programme executes and run properly for just 1 address in the list, however i can`t see all the output ( see just 1 line) when i run the perl script below:
============================================================
#!/usr/bin/perl -w
open (FILE, 'addr.txt');
foreach my $line (<FILE>){
$command = `mem_disp $line 80`;
print "$command";
}
close (FILE);
=============================================================
This gives the following output:

bash-3.2$ split.pl
Name "main::command" used only once: possible typo at ./split.pl line 5.
sh: line 1: 80: command not found
bash-3.2$ split.pl
sh: line 1: 80: command not found
Opening RO Data Memory File scp.ro
Opening Memory File CP2.16.0000000c.18.pmd.raw

12B21D20 12B6E500 *.... *
-------------------------------------------------------------------
 
Not really clear on your objective, so a shot in the dark
$pathToMemDisp = "/where/is/it";
chomp "$line";
print "$line";
$command = `$pathToMemDisp/mem_disp \"$line 80\"`;
 
use IPC::Run;


Gives you the results, a timeout limit, any errors spit back through STERR, etc. Works very nicely.


'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top