I would like to launch the batch file from php.
exec("cmd.exe /c(drive name)aaa.bat";
If aaa.bat is on the php server
as is usually the case with
What happens to the pass designation?
Also, if it is on a particular folder on a program in the bat file,
What should I do?
copy (drive name) aaa.txt (drive name) bbb.txt
Thank you for your cooperation.
I think the local environment is Windows, but what is the operating system of php's server?
It's like Linux.
php batch-file
As a pre-file path issue, you cannot run cmd.exe directly on Linux because the executable file format is different on Windows and Linux operating systems.Since the server running php is Linux, the file to run with the exec
function must be an executable file in the Linux format.There is an indirect way to run cmd.exe on Linux, but it does not solve this problem efficiently.
What is called a batch file in Windows is called a shell script in a typical Linux operating system.If you really want to run an external script, you will have to write a shell script and run it via a shell such as sh
or bash
.
But as a matter of fact, why do you want to run an external script? Can't you write it as a php program? If you can write it as a php program, you can absorb the difference between batch files and shell scripts.For example, you can copy files using php's copy()
function.
Based on these assumptions, you can specify the file using the Linux file path method on top of the Linux OS.
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.