Link to home
Start Free TrialLog in
Avatar of jsm11482
jsm11482

asked on

getting return result from executing

Hi, I need to execute another program from within my program and capture the result.  For example:

executing "bin/date +%H" will return "14" if it is 2 o clock
i need to capture the "14" into a variable int hr

i tried this:

int hr=execve("/bin/date","+%H",envp);

but all that does is run the date program, output the "14" and then it does not return a value.

I know that execve does not return a value unless it fails.

What command can I use to execute another command and get the output of it?

Sorry so long.
Thanks,
Josh
ASKER CERTIFIED SOLUTION
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jsm11482
jsm11482

ASKER

perfect, thanks!