Forum Moderators: coopster

Message Too Old, No Replies

calling a CGI which outputs XML

         

sdani

12:34 pm on Aug 20, 2006 (gmt 0)

10+ Year Member



Greetings all,

I have a command line utility, which generates its output on command line as XML.

What is the best way to call this exe in cgi-bin and parse its result from php?

I was reading about it and found a way like:
$result=echo exec('myexe 2&>1')

but its not working for me.

Thanks
sdnai

coopster

4:18 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have a closer look at the exec() [php.net] function. The second optional argument will contain an array of your xml output.

sdani

6:13 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



Thanks coopster,

I was able to figure that out. I also tried shell_exec and that worked well too.

So, is there any opinion / reason on which one is better / recommended based on experience.

Thanks

coopster

7:15 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You mean differences between exec and shell_exec? To the best of my knowledge it is merely the optional arguments and the returned values that are different. Either one executes system commands -- as will the backtick operator [php.net].