Executing a shell script from a PHP script

后端 未结 4 795
时光取名叫无心
时光取名叫无心 2020-11-27 05:55

I want to execute a Bash script present on the system from a PHP script. I have two scripts present on the system. One of them is a PHP script called client.php

4条回答
  •  执念已碎
    2020-11-27 06:23

    I was struggling with this exact issue for three days. I had set permissions on the script to 755. I had been calling my script as follows.

    
    

    My script was as follows.

    #!bin/bash
    find . -maxdepth 1 -name "search*.csv" -mmin +0 -exec rm {} \;
    

    I was getting no output or feedback. The change I made to get the script to run was to add a cd to tmp inside the script:

    #!bin/bash
    cd /tmp;
    find . -maxdepth 1 -name "search*.csv" -mmin +0 -exec rm {} \;
    

    This was more by luck than judgement but it is now working perfectly. I hope this helps.

提交回复
热议问题