how to invoke external progrmme and capture its output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • korcanucar
    New Member
    • Aug 2012
    • 1

    how to invoke external progrmme and capture its output

    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:
    Code:
    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:
    =============== =============== =============== ===============
    Code:
    #!/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:
    Code:
    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 *.... *
    -------------------------------------------------------------------
    Last edited by Frinavale; Aug 3 '12, 02:52 PM. Reason: Added code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    That looks to be an error from the running of the command on line 4. If I were you I would drop into the shell and execute the command the way that the script is and ensure that it works the way that you expect.

    Regards,

    Jeff

    Comment

    Working...