Perhaps it's a security issue. Perhaps it's something else, but for the life of me, I haven't been able to get a PHP script working with a batch file I've created on an XP machine running WAMP.
Here's the scoop. I need to obtain the newest .csv files from a remote SFTP every day and then perform certain functions on these files and import them over to their respective MySQL tables on a database.
I have an old-school DOS batch file created that will create a directory with the current date, move the existing .csv files into said directory, and then open up winscp or psftp to log onto the SFTP and obtain the new .csv files. These files have several different names and then random time/datestamps trailing in their file names.
My script for both PSFTP or WinSCP basically instructs the program to log on and get/mget *.csv. Upon successful retrieval of these .csv files, they are renamed to a format that my other scripts will read. All of this is handled in my batch file, let's call it script.bat.
If I run script.bat from a command prompt in Windows, everything runs beautifully. What I've been trying to do is get this to work on a PHP page so any one in my intranet can run this from a web browser and it'll perform said functions on the server and do it automatically.
My PHP script is in the same directory as the script.bat and I'd access it from the browser. The code just calls upon the script.bat, and in this fashion, all the DOS commands work fine, but the winscp/psftp does not work correctly (I mention both, because I'll take whichever one ends up working). I do not receive any error messages in the PHP error log, or the Apache error log. I've even tried procmon to find anything with an ACCESS DENIED result, but have been unable to find anything there as well. If I'm monitoring the Task Manager when the script is run from a browser, I see a process of winscp.exe or psftp.exe open up but not increase in memory size or cpu allocation, and it just sits there as an open/held process.
Any ideas what I'm doing wrong or what I need to look for? I've read everything on php.net I've found in terms of accessing exec() functions on Windows. I've also tried system(), shell_exec(), etc.
I hope whoever reads this was able to follow my explanation of said plight. Thanks in advance.
Here's the scoop. I need to obtain the newest .csv files from a remote SFTP every day and then perform certain functions on these files and import them over to their respective MySQL tables on a database.
I have an old-school DOS batch file created that will create a directory with the current date, move the existing .csv files into said directory, and then open up winscp or psftp to log onto the SFTP and obtain the new .csv files. These files have several different names and then random time/datestamps trailing in their file names.
My script for both PSFTP or WinSCP basically instructs the program to log on and get/mget *.csv. Upon successful retrieval of these .csv files, they are renamed to a format that my other scripts will read. All of this is handled in my batch file, let's call it script.bat.
If I run script.bat from a command prompt in Windows, everything runs beautifully. What I've been trying to do is get this to work on a PHP page so any one in my intranet can run this from a web browser and it'll perform said functions on the server and do it automatically.
My PHP script is in the same directory as the script.bat and I'd access it from the browser. The code just calls upon the script.bat, and in this fashion, all the DOS commands work fine, but the winscp/psftp does not work correctly (I mention both, because I'll take whichever one ends up working). I do not receive any error messages in the PHP error log, or the Apache error log. I've even tried procmon to find anything with an ACCESS DENIED result, but have been unable to find anything there as well. If I'm monitoring the Task Manager when the script is run from a browser, I see a process of winscp.exe or psftp.exe open up but not increase in memory size or cpu allocation, and it just sits there as an open/held process.
Code:
<?php
exec("script.bat");
?>
Any ideas what I'm doing wrong or what I need to look for? I've read everything on php.net I've found in terms of accessing exec() functions on Windows. I've also tried system(), shell_exec(), etc.
I hope whoever reads this was able to follow my explanation of said plight. Thanks in advance.