kirbyfooty.com
September 03, 2010, 04:43:53 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: 12th July 2009 -  I have noticed some of the attached images to some postings have been corrupted. Unfortunately I have no way of recovering them at this stage. Sorry for the inconvenience.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SFTP (Secure FTP)  (Read 1420 times)
RockFox
Full Member
***
Posts: 12



WWW
« on: July 31, 2007, 01:37:40 PM »

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
Logged

/RockFox at Slippery Rock University of Pennsylvania USA
Ian Cook
Administrator
Hero Member
*****
Posts: 757



WWW
« Reply #1 on: July 31, 2007, 05:20:57 PM »

Hi RockFox
Thanks very much for sharing your solution.
I'm sure it will help others!!

Ian Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!