Viewed   107 times

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

 Answers

1

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.

command1 ; command2     (run both uncondtionally)
command1 && command2     (run command2 only if command1 succeeds)
Sunday, August 28, 2022
 
memob
 
2

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);
Friday, December 9, 2022
3

Try using the direct path of the application (/usr/bin/unrar of whatever), it sounds like php can't find the application.

Thursday, September 1, 2022
3

If you're wanting to run commands from your PHP application I would recommend using the Symfony Process Component:

  1. Run composer require symfony/process

  2. Import the class in to your file with use SymfonyComponentProcessProcess;

  3. 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');
 
Wednesday, November 30, 2022
5

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.

Wednesday, September 28, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :