Run .sh file using exec Laravel PHP

后端 未结 3 1873
灰色年华
灰色年华 2021-01-14 20:15

I am trying to run a .sh file that will import a excel file to my database. Both files are in same directory inside the public folder. For some reason the exec command isn\'

3条回答
  •  余生分开走
    2021-01-14 20:33

    I know this is a little late but I can't add a comment (due to being a new member) but to fix the issue in Windows " 'sh' is not recognized as an internal or external command, operable program or batch file." I had to change the new process from:

    $process = new Process('sh /folder_name/file_name.sh');
    

    to use the following syntax:

    $process = new Process('/folder_name/file_name.sh');
    

    The only problem with is that when uploading to a Linux server it will need to be changed to call sh.

    Hope this helps anyone who hit this issue when following the accepted answer in Windows.

提交回复
热议问题