Solved

FTP Error Control on the AS400 through Batch

Posted on 2015-01-08
4
632 Views
Last Modified: 2015-01-08
Hi.
I have an iSeries V7.R1 and a CL batch job that uses FTP and an FTP command file.
The CL calls a series of programs that create files for me to hook up via FTP and PUT and GET data files.
This CL is run in the job scheduler at night and in the day without human help.

Occasionally the FTP wont connect but the FTP command file keeps on going, only to display in the log as "there must be a connection first" before putting or getting, etc.

My question is, is there a way to monitor an error within the FTP command file, possibly stop the process and pass that problem back to the CL that called the FTP command file so we can attempt a re-do, without all for the processes failing and having to manually correct it.

Its not a problem that happens very often, but when it does, we have to manually recreate data to send back up there on the next run.

Thanks in Advance.
Rj
0
Comment
Question by:RjCoats
  • 2
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Gary Patterson
Comment Utility
Assuming you're using a method like this:

http://www.itjungle.com/tfh/tfh070703-story04.html

you'd just write code to parses the FTP session output file and look for errors in the log  based on what you find, you'd take the appropriate action.

In recent years, I've been using the Expect scripting language to automate sftp sessions (most places are getting away from ftp for external transfers due to security requirements), but the same technique can be applied to FTP and any other interactive unix-style utility, for that matter.  Expect has very sophisticated capabilities for scripting interactive utilities, and you can find extensive documentation and examples online.  Scott Klement has a brief example in this presentation:

http://www.scottklement.com/presentations/Setting%20up%20and%20Scripting%20the%20OpenSSH,%20SFTP%20and%20SCP%20Utilities%20on%20IBM%20i.pdf
0
 

Author Comment

by:RjCoats
Comment Utility
Gotcha. Thanks Gary. Was hoping there was some sort of method in the FTP command to abort and send a message code to the CL that called it if something went wrong. Its usually that it just doesn't connect with the remote server.
 In the past research I had not been able to find one, but thought I'd ask.

Basically I have a CL that creates a file then ftp's it to a site, where they pick it up.
if it doesn't connect, the program just keeps on trucking as if it did, dishing out log messages "you must first open a connection" . I have a log that tells me what its doing, but nothing reading that log to find out. Doing that manually when we realize there was a transfer problem.
Thanks again.
Rj
0
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
Comment Utility
Ultimately, the native FTP client is designed to be an interactive tool.  It isn't designed as a program-to-program interface, so it doesn't do the things we expect an automated interface to do with regard to error handling.

This is one of those problems that has a lot of solutions.  

As I mentioned before, one common solution is to just parse the log.  It isn't a "pretty" solution, and it is "after the fact", but it works.

You can also use a third-party FTP tool like Trailblazer ZMod - it has the ability to do connection-detection and return a CPF message.  Automates FTP in CL very nicely.

You can also use a tool like Scott Klement's FTPAPI that provides a better batch interface to FTP, and specifically addresses the problem you are having detecting errors when doing batch file transfers.  

http://www.scottklement.com/ftpapi/

Personally, I like general-purpose tools, and Expect scripting is just that.  It is a cross-platform tool (IBM i, IBM mainframe, AIX, Linux, Unix, Windows, etc) that helps with automation of interactive command-line style tools like FTP, sFTP, Telnet, etc.  There is a bit of learning curve, but you can get it to do a lot of neat stuff (and you can find sample script online).  You can also use it to set an environment variable or set a return code that your CL program can detect to determine status.  If you decide to explore this route, let me know and I'd be happy to provide you with some example scripts.
0
 

Author Closing Comment

by:RjCoats
Comment Utility
Thanks.
Rj
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Help needed with DCM certificate renewal 9 330
End iSeries Job Programmtically 13 354
rpg d specs 5 75
iSeries Memory Utilization 2 63
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now