Hi, I tried to run a batch file via PHP functions exec()/passthru()/system() Basically my batch file picks all the xml files from the current location and ftp them to a server. None of the functions worked for me. Please help. All files are located at the configured IIS folder Test IIS batch file 'ftp.bat' contents are: cd c:\windows\system32 ftp -s:c:\TestIIS\ftp.txt 128.91.16.203 Code (markup): 'ftp.txt' file contains: ora10g ora10g cd /home/oracle/dit/XMLDIR prompt off lcd c:\TestIIS bin mput *.xml bye Code (markup): I tried the following code:. <?php if(isset($_POST['submit'])) { echo exec('ftp.bat'); echo "Done!"; } else { // display the form ?> <form action="" method="post"> <input type="submit" name="submit" value="DO IT!"> </form> <?php } ?> Code (markup): I am unable to run this file successfully. Please help
You need to do this another way. Parse the XML file and then use PHP built in FTP functions to do it. Of course this script is not going to work because usually you need root permissions (admin on windows) to execute files like this and that would just be a very bad security hole especially in this situation. Security is the issue here, I hope you understand.
Yes sir, I do understand security issues. This content wud be assessable to only concerned person. Problem is there would be thousands of xml files. how to make a loop to pick xml files one by one and parse them. FTP functions can work on one XML file only. Correct me if I am wrong. Also, Please provide a sample code to parse XML and ftp them using inbuild functions. It would be very greatful. Thanks.
Yeah I had the same issue. You need to setup permissions for cmd.exe and the folder in which you're executing it. Also, see here http://us2.php.net/manual/en/function.exec.php#85930