note 102399 added to function.system

[email protected] Fri, 11 Feb 2011 09:53:59 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Just a remark about a the fact that when you want use a variable in your system function, yous maybe find useful to call for trim() function too.
As exemple, let's take a file '/etc/config.cfg' containing the following lines :
EXEC=/usr/local/bin/enviro.sh
DIR=/home/fredmj
then you'll have to use trim() like that :

<?php
$CONFIGFILE = "/etc/config.cfg";
$DATACONFIG = file($CONFIGFILE);
foreach ($DATACONFIG as $line) {
$data = explode ('=',$line);
  switch ($data[0]) {
  case EXEC:
    $EXEC=$data[1];
  break;
   }
}

system(trim($EXEC)." --help");
?>

... in order to take into account the ' --help' argument. If not, the CR character will cut off any text after your $EXEC variable.
----
Server IP: 195.221.21.36
Probable Submitter: 82.126.126.227
----
Manual Page -- http://www.php.net/manual/en/function.system.php
Edit        -- https://master.php.net/note/edit/102399
Del: integrated  -- https://master.php.net/note/delete/102399/integrated
Del: useless     -- https://master.php.net/note/delete/102399/useless
Del: bad code    -- https://master.php.net/note/delete/102399/bad+code
Del: spam        -- https://master.php.net/note/delete/102399/spam
Del: non-english -- https://master.php.net/note/delete/102399/non-english
Del: in docs     -- https://master.php.net/note/delete/102399/in+docs
Del: other reasons-- https://master.php.net/note/delete/102399
Reject      -- https://master.php.net/note/reject/102399
Search      -- https://master.php.net/manage/user-notes.php