[php] system geeft niets door

Pagina: 1
Acties:

  • Tux
  • Registratie: Augustus 2001
  • Laatst online: 21-08 06:33
Ik ben bezig met een script dat een commando op een linux shell moet uitvoeren...
Alleen als ik
PHP:
1
2
system("commando",$output);
echo $output;

komt er GEEN output :(

met andere functies zoals passthru(); komt er alleen een getal of Array uit.

The NS has launched a new space transportation service, using German trains which were upgraded into spaceships.


Verwijderd

Heb je wel rechten om het commando uit te voeren?

Probeer dit anders eens:

PHP:
1
2
3
4
5
6
<?php

$output = `uptime`;
echo $output;

?>

  • nxt
  • Registratie: November 2001
  • Laatst online: 26-08 13:51

nxt

system() is just like the C version of the function in that it executes the given command and outputs the result. If a variable is provided as the second argument, then the return status code of the executed command will be written to this variable
oftewel
jou $output zou hooguit een statuscode moeten bevatten

probeer eens
PHP:
1
echo system("commando");

  • Tux
  • Registratie: Augustus 2001
  • Laatst online: 21-08 06:33
dat uptime test scriptje werkt wel gewoon, alleen mijn wvWare commando wat op de shell wel werkt hier niet :/


PHP:
1
2
3
4
5
<?php
$output = `/usr/local/bin/wvWare -c tis-620 -x '/home/Tux/wvHtml.xml' 
-d '/tmp/' '/home/Tux/blaat.doc' `;
echo $output;
?>



Output op de shell:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@Pluto www]# /usr/local/bin/wvWare -c tis-620 
-x '/home/Tux/wvHtml.xml' -d '/tmp/' '/home/Tux/blaat.doc'




<P align="left">
Hallo ik ben Pietje Puk :P
</P>



<P align="left">

</P>




</body>
</html>

The NS has launched a new space transportation service, using German trains which were upgraded into spaceships.


  • kvdveer
  • Registratie: November 2000
  • Laatst online: 06-11-2025

kvdveer

Z.O.Z.

Tux schreef op 16 oktober 2002 @ 21:23:
dat uptime test scriptje werkt wel gewoon, alleen mijn wvWare commando wat op de shell wel werkt hier niet :/


PHP:
1
2
3
4
5
<?php
$output = `/usr/local/bin/wvWare -c tis-620 -x '/home/Tux/wvHtml.xml' 
-d '/tmp/' '/home/Tux/blaat.doc' `;
echo $output;
?>



Output op de shell:
[snip]
Heb je in de bovenstaande code die linefeed er ook echt in staan, of is dat alleen voor de leesbaaheid?

Localhost, sweet localhost


Verwijderd

Het punt is dat system volgens mij inderdaad alleen maar de error_code teruggeeft, indien van toepassing. Als het commando succesvol uitgevoerd wordt, krijgt ie 0 terug, en PHP cast de int 0 bij de echo functie automatisch naar een string, en daarbij wordt volgens mij de string een lege string, ergo je ziet niets geoutput worden.

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Cronjob:
en PHP cast de int 0 bij de echo functie automatisch naar een string, en daarbij wordt volgens mij de string een lege string, ergo je ziet niets geoutput worden.

euh...
doe eens
PHP:
1
echo 0;
;)

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz

Pagina: 1