I want to execute the below command from PHP shell_script in Linux environment.
shell_exec('at 12:39 <<< "mkdir newfolder"');
I have tried in all the method of PHP to execute this script but it is not working. In terminal when I am running at 12:39 <<< "mkdir newfolder"
it is executing and the task is scheduling.But when I am trying the same script to run in php by using shell_exec it is not working.
You can understand the issues when you type at 12:39
it will show you to put the input and press Ctrl+d to complete execution. to make this in a single line here I am using <<<
Can anyone suggest how can I execute this script from the PHP?
shell_exec uses dash shell system by default : to make sure run php -r 'echo shell_exec("echo $0");'
and it will output 'sh' , and Dash does not have the <<< redirection operator.
Instead you could force the use of Bash and do something like:
shell_exec('/bin/bash -c \'at 12:39 <<< "mkdir newfolder"\'');
Hope this will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.