MostHated
asked on
Need to make a cronjob to check a remote ftp folder if file exists, if so, email me. Best to use Bash or PHP? (AS400, or Ubuntu)
Hello all,
As the title says I need to make a cronjob to check a remote ftp folder if a file exists. If so, it needs to email me. I have a Ubuntu web server I can use that is setup to email out and all that, is it best to try to make a bash script, or PHP to accomplish this? Does anyone know of any examples that might help me from having to start from scratch?
I currently have a bash script I have made that already connects to the ftp server and downloads, backsup the file into a folder, then copies the file to another folder on an as400, then deletes if off the FTP once it finishes, so I am wondering if maybe I can implement emailing into my bash script, but I am not even sure how to setup a cron job on an as400 (IBM iSeries 720). So I was thinking that maybe a PHP script on my Ubuntu web server might be easier to just connect, see if a file is in the folder if so, send me an email so I can then run my aforementioned script, or even better, make it run that script automatically.
If anyone has any suggestions, I would greatly appreciate it.
Thanks!
As the title says I need to make a cronjob to check a remote ftp folder if a file exists. If so, it needs to email me. I have a Ubuntu web server I can use that is setup to email out and all that, is it best to try to make a bash script, or PHP to accomplish this? Does anyone know of any examples that might help me from having to start from scratch?
I currently have a bash script I have made that already connects to the ftp server and downloads, backsup the file into a folder, then copies the file to another folder on an as400, then deletes if off the FTP once it finishes, so I am wondering if maybe I can implement emailing into my bash script, but I am not even sure how to setup a cron job on an as400 (IBM iSeries 720). So I was thinking that maybe a PHP script on my Ubuntu web server might be easier to just connect, see if a file is in the folder if so, send me an email so I can then run my aforementioned script, or even better, make it run that script automatically.
If anyone has any suggestions, I would greatly appreciate it.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then you're pretty much stuck with FTP. You can write and debug your FTP scripts from the browser address bar, subject to the limitations about environment variables. You can use ob_start() and ob_get_contents() or ob_get_clean() to capture messages from the script and write the messages in to the error_log file.
ASKER
Sorry for the late reply, will PHP be able to do the same commands with an SFTP connection?
I think so. This would be a research project for me. You might want to consider hiring a professional developer to help out. E-E has "Gigs."
ASKER