Our mainframe computer has an FTP client but it only does plain text
FTP. I needed a way to send files from the mainframe to another server
using secure FTP. I found a free SFTP client for Windows called WinSCP
at
http://winscp.net/I installed WinSCP on a local PC and also an FTP server. (Windows XP Pro
has a built-in FTP server).
I ftp the file from the mainframe to the PC. In the PC I have a KA alarm
to Watch File for a timestamp change. When this happens KA executes a
.cmd file. The .cmd file has a command line that invokes WinSCP. The
WinSCP parameters are in a WinSCP Script file.
When WinSCP is finished it returns a 0 return code if successful.
Otherwise it returns 1.
If a 1 is returned I wake up KA with another Watch File to send an email
to someone who can correct the problem.
Here is my .cmd file (green) and Script file (blue):
Rem Name: 70ftpfinance.cmd
Rem Author: Fran.Hensler@sru.edu
Rem Date: 28-JUL-2007
Rem This command file depends on three programs:
Rem 1) Any FTP server, I'm using Hummingbird InetD
Rem 2) Kirby Alarm Pro, a task scheduler and automatic reminder, http://www.kirbyfooty.com/ ($24.95)
Rem 3) WinSCP, a secure FTP client from http://winscp.net/ (Free)
Rem The mainframe VSE/ESA operating system does not have a secure FTP client.
Rem So files are FTPd to this PC in plain text
Rem Kirby Alarm (KA) has a Watch File feature which wakes up when a file timestamp changes.
Rem KA executes the following command line when the file named %1 is received in the PC C:FTP folder
Rem The WinSCP parameters are in file %1.txt
C:"Program Files"Winscpwinscp.exe /console /script=C:FTPScripts%1.txt 70ftpfinance@ftp.xxxxxx.edu
Rem WinSCP return code 0 if successful, otherwise it return 1
if errorlevel 1 goto error
exit
:error
Rem We want to wake up KA to send an email that the FTP has failed.
Rem A copy of a single file results in a file with the timestamp of the original file.
Rem KA has a Watch File for file latest.txt
Rem Here we copy append two files which results in a new timestamp to wake KA up.
Rem KA sends an email to several people notifying them of the error and the filename (%1)
Rem File latest.txt is attached to the email to show what file failed.
Copy %1.err+error.txt latest.txt
Rem Following will display a black screen with the message 4 times and then pause
echo off
echo
echo message FTP of %1 file failed. Try it manually.
echo message FTP of %1 file failed. Try it manually.
echo message FTP of %1 file failed. Try it manually.
echo message FTP of %1 file failed. Try it manually.
echo on
pause# SFTP of file 70sis to SyTEC
# Fran Hensler 26-Jul-2007
#
# Automatically answer all prompts negatively not to stall the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
# option confirm off
# Connect using a password
# open user:password@example.com
# Connect
open 70ftpfinance@ftp.xxxxxx.edu
# Change remote directory
put C:FTP70sis
# Disconnect
close
# Disconnect
close
# Exit WinSCP
exit