I want to display all the files that are modified after a specified date
the commands are
touch --date '2011-09-19 /home/ , find /home/
How i can execute this two commands in single exec statement.Thanks in advance
I want to display all the files that are modified after a specified date
the commands are
touch --date '2011-09-19 /home/ , find /home/
How i can execute this two commands in single exec statement.Thanks in advance
Problem solved with the following command:
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:wampbinphpphpVERSIONNUMBERphp-win.exe -f C:/wamp/www/path/to/backgroundProcess.php", 0, false);
Try using the direct path of the application (/usr/bin/unrar of whatever), it sounds like php can't find the application.
If you're wanting to run commands from your PHP application I would recommend using the Symfony Process Component:
Run composer require symfony/process
Import the class in to your file with use SymfonyComponentProcessProcess;
Execute your command:
$process = new Process(['rm', '/var/www/html/test.html']);
$process->run();
If you're using Laravel, you should be able to skip Step 1.
Alternatively, (if the process running php has the correct permissions) you could simply use PHP's unlink() function to delete the file:
unlink('/var/www/html/test.html');
If you want to run multiple commands within a single shell instance, you will need to invoke the shell with something like this:
cmd := exec.Command("/bin/sh", "-c", "command1; command2; command3; ...")
err := cmd.Run()
This will get the shell to interpret the given commands. It will also let you execute shell builtins like cd
. Note that this can be non-trivial to substitute in user data to these commands in a safe way.
If instead you just want to run a command in a particular directory, you can do that without the shell. You can set the current working directory to execute the command like so:
config := exec.Command("./configure", "--disable-yasm")
config.Dir = folderPath
build := exec.Command("make")
build.Dir = folderPath
... and continue on like you were before.
You can use either a
;
or a&&
to separate the comands. The;
runs both commands unconditionally. If the first one fails, the second one still runs. Using&&
makes the second command depend on the first. If the first command fails, the second will NOT run.