Sponsored Content
Top Forums Shell Programming and Scripting how to invoke external program and capture its output Post 302681453 by ekckabatop on Friday 3rd of August 2012 12:23:45 PM
Old 08-03-2012
how to invoke external program 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 
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 *.... *
-------------------------------------------------------------------

---------- Post updated at 11:23 AM ---------- Previous update was at 11:09 AM ----------

I think perl just cant see 80 in the command ..because the output is same as saying mem_disp <addr> without the number at the end..

Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 08-03-2012 at 01:30 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture output of program to file with limited filesize

I'm working on a script that will perform a backup, save a log of said backup and send the output to me in an email. Everything is working fine so far except that I can't figure out how to specify a maximum file size for the log file. I don't want a runaway log file jamming up the server.... (7 Replies)
Discussion started by: spectre_240sx
7 Replies

2. UNIX for Advanced & Expert Users

Invoke java program in different processc d

I have a simple script like this: for file in $dodfiles; do ./rundod $file done $dodfiles is an array of file names selected rundod is a script which invokes a java progrm which process a data file all the processing message logged into a log file in order to extract and analyze the... (1 Reply)
Discussion started by: liux99
1 Replies

3. Shell Programming and Scripting

Passing value to an external program problem...

This code is in my 'case' statement and it all else works fine. The problem I have is that the value in 'procno' is not passed on to the external program (fireit). It is passing all zeros instead of the actual process number. By the time I get to this case statement, I know the "Number" and... (1 Reply)
Discussion started by: giannicello
1 Replies

4. Shell Programming and Scripting

Invoke java program in script

Hey all, My boss tasked me with the job to write a script which would invoke various java programs, the thing is I don't know much about shell scripting so would you experts help me out? Here is the requirement - 2 applications written in java: App_A and App_B -... (0 Replies)
Discussion started by: mpang_
0 Replies

5. Shell Programming and Scripting

Invoke perl program from Ksh

Hi all, Can I invoke a perl script from Ksh script and pass parameters to the perl script. Please do help me.. thanks Maha (10 Replies)
Discussion started by: mahalakshmi
10 Replies

6. Shell Programming and Scripting

How to invoke a perl script from java program

Hi: I need to invoke a perl script from a java applet program in UNIX operating system.. Can you please suggest me!!! (4 Replies)
Discussion started by: grajesh_955
4 Replies

7. Solaris

How to invoke remote java program from ssh

How can i invoke java program from MC1, when I connect remotely to execute can I set classpath etc. ____________ <-------------->____________________ |..................|<-------------->|...............................| |..................|<-------------->|...............................|... (2 Replies)
Discussion started by: vishnu559
2 Replies

8. UNIX for Advanced & Expert Users

Invoke unix script using c program

hi i want to invoke a unix script in a C program and also return some value from the script to the C program to use that value further. Basically i am doing a Lookup operation in this unix script and returning the looked up data from a oracle database table.. please help me invoke as well... (1 Reply)
Discussion started by: somi2yoga
1 Replies

9. Shell Programming and Scripting

Script of invoke an email program

Is it possible that a shell script invokes a windows mailing application like Lotus Notes and creates a mail and sends it ? (2 Replies)
Discussion started by: csrohit
2 Replies

10. Shell Programming and Scripting

Problem while Invoke Shell Script function from Java Program

Hi, I have create a Shell Script, with one function. I want to call the script file in Java Program. It working fine. but the problem is the function in the Shell Script is not executed. Please suggest me, Regards, Nanthagopal A (2 Replies)
Discussion started by: nanthagopal
2 Replies
All times are GMT -4. The time now is 02:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy