invoking php?

B

Bush is a Fascist

Hi all,

Nobody in the php forum seems to know how to invoke
php properly from C, so I must ask here.

I am doing is the following, which seems to be by the book,
but then again I am finding very few explanations
on the subject.

setenv ("REQUEST_METHOD", "GET", !0);
setenv ("QUERY_STRING", "abc=123", !0);
system "/usr/local/bin/php myfile.php < dummyfile > foo";

Dummyfile can be empty or have data in it, yet
I keep getting an error:

"No input file specified."

Anybody know what's going on?

Thanks.
333
 
C

CBFalconer

Bush said:
Nobody in the php forum seems to know how to invoke
php properly from C, so I must ask here.

On the contrary, you must NOT ask known off-topic questions here.
 
S

Sensei

Who lit your tampon? Go be prissy somewhere else.

He is *totally* right:

setenv ("REQUEST_METHOD", "GET", !0);
setenv ("QUERY_STRING", "abc=123", !0);
system "/usr/local/bin/php myfile.php < dummyfile > foo";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The line is NOT written in C, and the others can be written in another
language as well.

You'd better stick with PHP related newsgroups.
 
R

Red

On the contrary, you must NOT ask known off-topic questions here.

People who post orders like that make me want to post OT material here
just to piss them off.
 
C

Chris Croughton

People who post orders like that make me want to post OT material here
just to piss them off.

Me too. What is the airspeed of an unladen sparrow?

Chris C
 
S

SM Ryan

# On Fri, 22 Jul 2005 00:42:47 -0400, Red
#
# > In article <[email protected]>, (e-mail address removed) says...
# >> Bush is a Fascist wrote:
# >> >
# >> > Nobody in the php forum seems to know how to invoke
# >> > php properly from C, so I must ask here.
# >>
# >> On the contrary, you must NOT ask known off-topic questions here.
# >
# > People who post orders like that make me want to post OT material here
# > just to piss them off.
#
# Me too. What is the airspeed of an unladen sparrow?

http://www.garden-birds.co.uk/information/flight.htm

17 to 24 mph.
 
K

Keith Thompson

Chris Croughton said:
Me too. What is the airspeed of an unladen sparrow?

This topic came up last year. You've repeated (deliberately?) the
error made back then; the original question was about an unladen
*swallow*.

The answer is about 60 to 66 kilofurlongs per fortnight.

CBFalconer's original answer of 27 kilofurlongs per fortnight may have
been about right for sparrows.
 
C

Chris Croughton

# On Fri, 22 Jul 2005 00:42:47 -0400, Red
#
# > In article <[email protected]>, (e-mail address removed) says...
# >> Bush is a Fascist wrote:
# >> >
# >> > Nobody in the php forum seems to know how to invoke
# >> > php properly from C, so I must ask here.
# >>
# >> On the contrary, you must NOT ask known off-topic questions here.
# >
# > People who post orders like that make me want to post OT material here
# > just to piss them off.
#
# Me too. What is the airspeed of an unladen sparrow?

http://www.garden-birds.co.uk/information/flight.htm

17 to 24 mph.

Interesting, that's the answer I got (for a house-sparrow,
hedge-sparrows are smaller which may make a difference). I measured it
in a car chasing the bird down a lane...

(The answer should, of course, have been a question about what sort of
sparrow I meant, at which point I would vanish in a puff of smoke...)

Chris C
 
C

Chris Croughton

This topic came up last year. You've repeated (deliberately?) the
error made back then; the original question was about an unladen
*swallow*.

I do know the original, very well, my question was about a different
bird (it seems that my measurements of "20 MPH give or take a bit" were
correct according to the posted link).
The answer is about 60 to 66 kilofurlongs per fortnight.

African or European?
CBFalconer's original answer of 27 kilofurlongs per fortnight may have
been about right for sparrows.

No, it's much too slow. They are slower than swallows on average, but
they still achieve around 45 to 60 kilofurlongs/fortnight (a unit with
which I am more familiar as furlongs per millifortnight)...

Chris C
 
M

Mark McIntyre

No, it's much too slow. They are slower than swallows on average, but
they still achieve around 45 to 60 kilofurlongs/fortnight (a unit with
which I am more familiar as furlongs per millifortnight)...

I'm sorry, this sketch has become far too silly. I demand that you
perform the Fish Dance at once.
 
C

Chris Croughton

I'm sorry, this sketch has become far too silly. I demand that you
perform the Fish Dance at once.

Albatross!

(The speed of light is 1 foot per nanosecond, as a first approximation.
Far more useful than the more accurate 186282.4 miles per second...)

What's the silly unit managers like to use to measure programming
productivity? Lines of code per man-week or something?

Chris C
 
S

Steve Summit

z333r said:
setenv ("REQUEST_METHOD", "GET", !0);
setenv ("QUERY_STRING", "abc=123", !0);

Gad, that's clumsy! I hate stuffing parameters through the
environment like that! (Not your fault, of course. It's bad
enough from the shell -- see below -- but somehow it seems even
worse in C, with those explicit setenv calls.)

I'd recommend replacing those "!0" thingies with "1" or "TRUE",
though -- rederiving the value of "true" on-the-fly in this way
strikes me as obfuscatory.
system "/usr/local/bin/php myfile.php < dummyfile > foo";

I assume you mean

system("/usr/local/bin/php myfile.php < dummyfile > foo");

(But if not, that may be your problem right there.)

I suspect you'll eventually want to stuff the input into php by
invoking it with popen(), not system().
Dummyfile can be empty or have data in it, yet
I keep getting an error: "No input file specified."
Anybody know what's going on?

No, not yet. What happens if you bypass C entirely and invoke

REQUEST_METHOD=GET QUERY_STRING=abc=123 /usr/local/bin/php myfile.php < dummyfile

directly from the shell command line?

Steve Summit
(e-mail address removed)
 
R

Richard Bos

Mark McIntyre said:
I'm sorry, this sketch has become far too silly. I demand that you
perform the Fish Dance at once.

That's the Fish _Slapping_ Dance, you snotty-faced heap of parrot
droppings!

Oh, I'm sorry, this isn't comp.lang.abuse.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top