Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FTP Error Control on the AS400 through Batch

Posted on 2015-01-08
4
Medium Priority
?
958 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Gary Patterson
ID: 40538147
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
ID: 40538416
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 35

Accepted Solution

by:
Gary Patterson earned 2000 total points
ID: 40538581
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
ID: 40538792
Thanks.
Rj
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 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