C Programming Language: How To Pull In Information From The System? (269 Views)
Reply
Valued Contributor
tony j. podrasky
Posts: 112
Registered: ‎04-19-2000
Message 1 of 4 (269 Views)
Accepted Solution

C Programming Language: How To Pull In Information From The System?

Hello Everyone;

 

I want to run the <apm> command, from withing a C program, and get the program to receive the output - so that I can display it in an xsession (window) on my screen.

 

I've used the <system> call to tell the O/S what to do - but I don't know where to look to find out how to issue a system call and have the program receive the output.

 

Any ideas are appreciated.

 

regards,

tonyp

 

REMEMBER: Once you eliminate your #1 problem, #2 gets a promotion.
Acclaimed Contributor
Dennis Handly
Posts: 25,188
Registered: ‎03-06-2006
Message 2 of 4 (243 Views)

Re: C: How to pull in info from the system?

The correct function is popen(3) with the "r" parm.  Or you could use pipe(2) with fork(2)/exec(2).

And example of the reverse popen(3) is here:

http://h30499.www3.hp.com/t5/Languages-and-Scripting/Facing-problem-with-popen-system-call-in-HP-UX/...

Valued Contributor
tony j. podrasky
Posts: 112
Registered: ‎04-19-2000
Message 3 of 4 (228 Views)

Re: C: How to pull in info from the system?

Hello Dennis;

 

All I needed was the <popen> function.

 

Worked as expected.

 

Now I can re-write all the programs that I wrote that use [system abcdefg >> output] and then do an <open> of "output".

 

The link you left was a bonus!

 

Thank you for your help!

 

regards,

tonyp

REMEMBER: Once you eliminate your #1 problem, #2 gets a promotion.
Acclaimed Contributor
Dennis Handly
Posts: 25,188
Registered: ‎03-06-2006
Message 4 of 4 (222 Views)

Re: C: How to pull in info from the system?

>Thank you for your help!

 

If the posts were helpful, please click on the kudos stars, both here and at the link.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.