Hi Experts,
I am setting up an application hosting service and my client needs to be able to transfer data files which will be imported into the application. For security reasons the client doesn't have direct access to the application server except via HTTP(S). Instead I have configured a Linux "bastion" server (CentOS) and the client can transfer files to the bastion server via S
FTP.
What I want to do is create a batch file (.bat) or a VB Script file (.vbs) which will reside on the application server (Windows Server 2003). This batch/vbs file will be executed by means of a Windows Scheduled Task and it will connect to the bastion server and check to see if there are any interface files to be collected - if so they will be transferred to the application server and processed by the application (ie: the data will be imported).
I need help with the batch/vbs file. I have no idea how to establish a SFTP connection programmatically using either VB Script or Windows commands (in a batch file). My preference is for a VB Script file because I am comfortable programming in VB and it is relatively easy to write code which will check for particular file name formats, spool to log files, etc. Essentially the bit I need most help with is making the SFTP connection, retrieving a directory listing, transferring files from the bastion to the app server, and optionally deleting the files from the bastion once the transfer is complete.
Outline of the batch/vbs file for what I want to achieve:
* connect to bastion server with client credentials
* retrieve directory listing into array
* check filenames to see if they match the filename pattern agreed with client
* transfer valid files to "inbound" folder on application server
* delete files on bastion server (optional - the client may want to do this or they may want to leave the files)
* create log file with results of connection/transfer
* email log file to client
Cheers,
Paul
Start Free Trial