Click to See Complete Forum and Search --> : PHP functions
manual_overide
10-09-2000, 01:07 AM
I'm starting to teach myself some PHP. I'm experimenting with some functions and I want to be able to display my system's uptime on the page. I tried <?php system(uptime); ?> but all i get is nothingness.
What am I doing wrong??
I've also done the same thing with
<?php echo system(uptime); ?>
Thanks for any help
Darth Tminos
10-09-2000, 01:13 AM
It's all in the exec baby!
Here is an example in of my books:
For examle, you would use the following code to
perform a ping of a server five times and print the
output:
$command = "ping -c5 www.host.com (http://www.host.com)
exec($command, $result, $rval);
for ($i = 0; $i < sizeof($result); $i++) {
echo "$result[$i]<br>";
}
------------------
I hold it to be the inalienable right of anybody to go to hell in his own way. -- Robert Frost
C-x C-c power!
manual_overide
10-09-2000, 01:57 AM
OK. This SHOULD output something, but it doesn't. The code at least makes sense to the C++ part of my brain.
<?php
$command = "uptime";
exec($command, $return);
echo($return[0]);
?>
what's going on?
Darth Tminos
10-09-2000, 02:11 AM
I don't know what to say, but it works for me.
------------------
I hold it to be the inalienable right of anybody to go to hell in his own way. -- Robert Frost
C-x C-c power!
manual_overide
10-09-2000, 12:05 PM
Well, If anybody wants to see what's happening, go to http://manualoveride.darktech.org and veiw the source for the side frame. This is really starting to irritate me.
manual_overide
10-09-2000, 01:54 PM
hmmmm.... It seems as though I can't make any system calls at all. Does anybody know what is going on?
Thanks for any help
lone-nut
10-09-2000, 04:51 PM
Hey... dumb response = is PHP installed on yer server?
I have a PHP qeustion... should be ez for someone...
i'm trying to make a simple form using PHP
is it possible to pas the name value pair to itself...?
using a if else style thing like in CGI?
for example
if (some argument is passed){
process arguments..
} else {
print out form and prompt for input....
form action="this script"
}
bad pseudo code I know sorry...
i'm new to this...
I was using a seperate page for the output...
and aside from not working... I 'd really like
to do it like this...
any ideas..
thanks...
Sweede
10-09-2000, 05:10 PM
<?
if(isset($testvar)){
[stuff that the form processes]
exit;
}else{
?>
<form action="<?=$PHP_SELF?>">
<input type=hidden name=testvar value=1>
<submit>
</form>
<? } ?>
works great,
lone-nut
10-09-2000, 05:32 PM
hey cool thanks Sweede..
that looks a bit strange but I'll study it...
thanks fer the help brutha...
-ln
------------------
There is no pillow so soft as a clear conscience...
manual_overide
10-09-2000, 05:35 PM
Yeah, php is installed. I just can't get it to do any system calls. Other stuff like date and time and stuff works great
Sweede
10-10-2000, 05:10 PM
if you want to see one of my working scripts that use the above, just let me know.
as for system(), exec(), i just use `` (backticks),
$data = `uptime`;
manual_overide
10-11-2000, 12:02 AM
Well, I tried using backticks, and I got this error:
Warning: Cannot
execute using
backquotes in safe
mode in
/usr/local/httpd/htdocs/sideframe.php3
on line 15
What does that mean?