PHP shell_exec geeft niks?!

Pagina: 1
Acties:

Onderwerpen


Verwijderd

Topicstarter
Kan iemand mij vertellen waarom de volgende code niks geeft?

code:
1
2
3
4
<?
$a = shell_exec("/usr/local/bin/xmllint --valid --noout dtdtest.xml");
echo $a;
?>


De file dtdtest.xml ziet er zo uit:
code:
1
2
3
4
5
6
7
8
9
<?xml version="1.0" ?>
<!DOCTYPE note SYSTEM "test.dtd">
<note>
<bar>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>


De file test.dtd ziet er zo uit:

code:
1
2
3
4
5
6
<?xml version="1.0" ?>
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>


Zoals je ziet zit er een fout in de XML omdat de tag bar niet in de DTD staat.
Als ik aan de commandline run:

/usr/local/bin/xmllint --valid --noout dtdtest.xml

Dan krijg ik dit:

code:
1
2
3
4
5
6
dtdtest.xml:9: error: Opening and ending tag mismatch: bar and note
</note>
       ^
dtdtest.xml:10: error: Premature end of data in tag note

^


Als ik echter het bovenstaande php script run krijg ik niks!

Why oh why?

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06 13:31

drm

f0pc0dert

[nohtml]shell_exec vangt de stdout af, niet de stderr (de streams waar resp. output en errors naar gestuurd worden). Je zou stderr in je command even kunnen redirecten naar stdout, door
code:
1
[opdracht] 2> /dev/stdout
te gebruiken. Je moet er dan wel zeker van zijn dat je bash als shell heb ingesteld, of een soortgelijke, want in csh bijv werkt 't weer anders :)

edit:
om erachter te komen wat je shell is, kun je kijken in de $_ENV [ 'SHELL' ] variabele, trouwens :)

[ Voor 14% gewijzigd door drm op 19-12-2002 12:52 ]

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


Verwijderd

Topicstarter
Fantastisch! Mijn dank is groot :)