System folder
| From: | Dan Allen | Date: | Sat, 25 May 2002 11:41:28 +0000 |
| Subject: | System folder | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-6416@lists.php.net to get a copy of this message | ||
Stig,
Okay, I finished the first version of System_Command but on the
pear.php.net page there is no folder (category) for System...could
you create one or tell me how to make a folder?
I think you are really going to like this one...let me give you a
quick example...Say I want to reformat an xml string I have using
Daniel Veillard's xmllint from libxml2...you just go
$xml = '<?xml version="1.0"?>
<doc>
<child attribute="value"/></doc>';
$cmd = new System_Command('sh'); // that shell is optional
$cmd->setCommand('echo', $xml); // each argument to the setCommand
function is an argument in the commandline...bascially every space
you type on the commandline makes another argument
$cmd->setOperator('|'); // continue building the command, adding a
pipe...the function validates that a pipe is allowed here and
continues
$cmd->setCommand('xmllint', '-'); // continue building the command,
add another command...the function validates that a command is
allowed here and continues
if (System_Command::isError($result = $cmd->execute())) {
echo $result->getMessage() . ' ' . $result->getDebugInfo();
}
else {
echo $result;
}
$cmd->reset();
$cmd->setCommand('ls');
echo $cmd->execute();
So you get the idea...should be ready to go for a release as soon as
the folder is in place.
Dan