Re: returning file info to C code



shorti wrote:
Hello, I am a C coder but new to Perl. I am running in an AIX
environment. I was wondering if there was a Perl way to return string
data (or larger int values) to a C program? For instance, if I use
the command :

ps aux | grep process123 my out put would look like this:

emextra 45304 0.0 0.0 7344 6120 - A 20:08:01 0:00
process123
emextra 97034 0.0 0.0 3184 1984 - A 20:11:25 0:00
process123
emextra 123294 0.1 0.0 5100 3580 - A 20:06:47 0:37
process123
emextra 186828 0.0 0.0 2328 912 - A 20:07:22 0:02
db2agent (ERMM)
rsuser 8448 0.0 0.0 2900 284 - A 20:13:24 0:00
process123
rsuser 11576 0.0 0.0 2492 312 - A 20:13:24 0:00
process123
rsuser 14110 0.0 0.0 1576 288 - A 20:13:24 0:00
process123
rsuser 23584 0.0 0.0 2120 324 - A 20:13:24 0:00
process123
rsuser 24108 0.0 0.0 2540 280 - A 20:13:24 0:00
process123
rsuser 26800 0.0 0.0 1468 356 - A 20:13:24 0:00
process123

I want to retrieve the 2nd and 5th columns of the output. I *think* I
can figure out a way for Perl to get these columns but is there a way
to return these values to my C program?

Any advise would be appreciated

Piping your output through this Perl filter will do what you describe.

perl -ane "print qq(@F[1,4]\n)"

HTH,

Rob
.



Relevant Pages

  • Re: Using References to Formats, Examining Scalars With Devel::Peek
    ... the format to be able to refer to it by another name didn't occur to me. ... Seems most of the fields are the same as for the rest of the Perl ... from integer to double and how frequently the string portions are updated. ... Using an operator or a built-in with a double and an int usually converts ...
    (comp.lang.perl.misc)
  • Cant Compiling perl5.8.8 on FreeBSD6.2
    ... WITH_DEBUGGING=yes Build perl with debugging support. ... First let's make sure your kit is complete. ... What is the file extension used for shared libraries? ... I'll use sprintf to convert floats into a string. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: use of DBI; I am getting multiple error messages mixed in with ?the correct output.
    ... But I'm not talking about C++ or Java or SQL. ... This is a perl newsgroup. ... to means by a "defined null string", as opposed to an undefined value. ... And where exactly are you getting the idea that the empty string is a ...
    (comp.lang.perl.misc)
  • Re: Perl Strings vs FileHandle
    ... Just wanted to run this through Perl gurus to see if fit is ... testing it every time through the loop. ... The comparison test to the string '1' is superfluous. ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ...
    (comp.lang.perl.misc)
  • Re: Working with Source Code to Insert Copyright Statements as a Header
    ... Paul Lalli wrote: ... Where could I go to find some samples of PERL code that do the ... ascii english text, etc etc etc) at the top of the file, from a string: ... `perldoc Tie::File` at the command line to read its documentation. ...
    (comp.lang.perl.misc)