techdoc6
asked on
PHP Exec Pipes
I'm trying to run a simple unix command via php, but php seems to be ignoring everything to the left of the pipe( | ).
In the example below, I'm trying to pipe the argument '/var' to the 'ls' command, which should give the output of the /var directory. Instead it gives the output of php's working directory, meaning that ls thinks there are no arguments coming in from the pipe.
Ultamitly, I want to get this running with a gpg command for encryption, but that should be pretty easy once I figure out why its not accepting pipes.
In the example below, I'm trying to pipe the argument '/var' to the 'ls' command, which should give the output of the /var directory. Instead it gives the output of php's working directory, meaning that ls thinks there are no arguments coming in from the pipe.
Ultamitly, I want to get this running with a gpg command for encryption, but that should be pretty easy once I figure out why its not accepting pipes.
$command = 'echo /var | ls';
$return = shell_exec($command);
var_dump($return)
//returns the contents of php's working directory instead of the /var directory
ASKER
Yea, that works fine. Its just when a pipe is introduced that problems arise. I've tried a few other test commands to see if the piping is working, and every time it seems as though the left side of the pipe is being ignored.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, that text file was my us50.txt
$command = 'ls /var';
??