[PHP] (To Rasmus and/or Developers) PHP as CGI env variables

2002-01-10 Thread fabrizio

Hi,
I'm trying to let Webmin execute a script where I can use php as scripting 
language... (It will be good to work with a language as php in a remote administration 
server, as root!)

Now the STRANGE problem:

When I execute a test.cgi program from Webmin, it's executed as root, as it was from 
command line... that's good. The problem is that Webmin execute well _every_ program I 
tried , EXCEPT php !

It seems that php needs some env variables to work well, and these variables aren't 
provided from the Webmin program, so to solve the problem I've to first understand WHY 
php does not work...

Here are some tests:

1) Executing a php that produce some output, or create a file works only when called 
from a login shell, not in Webmin
2) Executing a script that invoke at with the previous script doesn't work as 
well... from atq the scheduled processes are the same, but the one invoked from a 
login shell works, the invoked from Webmin not at all...

... what to do ?!?

thanx very much,
prakash





Re: [PHP] (To Rasmus and/or Developers) PHP as CGI env variables

2002-01-10 Thread fabrizio

Thank you for your prompt reply...

The problems seem to be some env variables (maybe I'm wrong) when
executing PHP as CGI...
I better explain with 2 samples:

file aaa.cgi

#!/bin/bash
echo Content-type: text/plain
echo
echo aaa
touch /home/test.txt

file bbb.cgi

#!/usr/local/bin/php -q
?php
echo Content-type: text/plain\n\n;
echo aaa\n;
$fd = fopen(/home/test.txt,w);
fclose($fd);
?

Now, the 2 programs are quite the same... (if test.txt does not exist...)
But, the 2 programs behave the same way only if you execute them _from
command line_.
If you execute them from the Webmin interface (very good for remote
administration, that lets execute programs with user root), they behave
differently:
aaa.cgi is the same, displays aaa on the remote web-browser, and creates
(well, if text.txt doesn't exist) a local file.
bbb.cgi does nothing, sends no http headers, no aaa, and does not create the
file...

It seems that PHP needs some env variables, and without them, it suddenly
stops without parsing the file... am I right ?!?

I've also tried to escape from this problem (until understood and solved)
with a third program:

file ccc.cgi

#!/bin/bash
/usr/bin/at -f /path/bbb.cgi now+1minute
touch /home/test2.txt

If I call ccc.cgi from Webmin and then from command line, the 2 executions
are scheduled properly, and look really the same (root user,same
program,...) but the task scheduled from Webmin is not executed properly...
the php seems to stop with no output.

Also with a file like this:

file ddd.cgi

#!/bin/bash
/path/bbb.cgi 21  test3.txt

show that php really has no output on stdout or stderr (test3.txt is
created, but 0 bytes long when invoked from Webmin!)

So, the BIG problem is: if Webmin can execute all programs, running them as
root, WHY doesn't work well with php scripts ?!?
I think that the PHP need something, and not having it it suddenly stops...
but what ?!?

Are there some developer that can help ?!?

(Writing Webmin modules in perl is not good, if you work mainly with php,
and webmin can be the best remote administration utility...)

thanks to all,
waiting for some news...
prakash



 Ok, this is not really clear to me. Does it do anything? perharps give an
error ??
 Did you try writing all output to a file, so you can actually see the
error ??

 for example:

 ls  21  /tmp/out

 will write 'ls' his stdout AND stderr to /tmp/out

 Maybe, do you need to include the full path to your php binary ??


 Hi,
 I'm trying to let Webmin execute a script where I can use php as
scripting language... (It will be good to work with a language as php in a
remote administration server, as root!)
 
 Now the STRANGE problem:
 
 When I execute a test.cgi program from Webmin, it's executed as root, as
it was from command line... that's good. The problem is that Webmin execute
well _every_ program I tried , EXCEPT php !
 
 It seems that php needs some env variables to work well, and these
variables aren't provided from the Webmin program, so to solve the problem
I've to first understand WHY php does not work...
 
 Here are some tests:
 
 1) Executing a php that produce some output, or create a file works only
when called from a login shell, not in Webmin
 2) Executing a script that invoke at with the previous script doesn't
work as well... from atq the scheduled processes are the same, but the one
invoked from a login shell works, the invoked from Webmin not at all...
 
 ... what to do ?!?
 
 thanx very much,
 prakash
 
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]