execute two shell commands in single exec php statement
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)
php command line exec() multiple execution and directories?
(Sorry my bad English)
On Linux you can add your Commands in a Shell Script.
You can put this in any file:
#!/bin/bash
cd /../Desktop/FolderName
export PATH=$PATH:`pwd`
EXECUTE COMPILER
And save this as fille.sh
Then, add execution permissions:
chmod +x path/to/file.sh
From PHP, you can call this Script executing:
shell_exec('sh path/to/file.sh');
Hope this helps!
php shell_exec multiple commands at once in background
You should try using exec
rather than shell_exec
, and redirect all output to /dev/null
. Something like:
exec("(sleep 4 && ... --webspace-off ".$domain_name.") > /dev/null 2>&1 &");
(Note the ()
around the commands: you need to catch the output stream of both sleep
and your wrapper.)
Edit: and make real sure that you validate $domain_name
. Without validation and with
$domain_name = "; rm -rf ...";
you're in trouble...
Related Topics
Curl - Load a Site with Cloudflare Protection
Laravel Says "Route Not Defined"
Is This the Most Efficient Way to Get and Remove First Line in File
Parsing Http_Range Header in PHP
Http://Localhost/ Not Working on Windows 7. What's the Problem
Convert Number into Xx.Xx Million Format
Request Exceeded the Limit of 10 Internal Redirects
Xml Parser Error: Entity Not Defined
Remove Null, False, and '' - But Not 0 - from a PHP Array
Fetching One Row Only with MySQLi
PHP Password_Verify Not Working with Database
Compress/Archive Folder Using PHP Script
Add Attachment Through PHPmailer