Volume 7, Number 13 -- April 4, 2007

FTP Means 'First Try Pinging'

Published: April 4, 2007

by Cletus the Codeslinger

File Transfer Protocol, or FTP, was obviously designed by academics. While academics are OK people (after all, my editor, Ted Holt, is a part-time instructor at a community college), they are not familiar with what goes on at the factory (like the one where I work full-time). That means that making FTP (and other Unix-type applications) work dependably in an automated environment can be a challenge. Here's a tip that can help.

FTP was intended to work this way: a human types a command into a computer. The computer responds. The human types another command. The computer responds. Etc. Etc. And so forth. Ad nauseum. That's all well and good, but who wants to crawl out of bed at 3 a.m. every day to send a file to somebody?

Unix has a "solution" to this problem--scripting. Put the FTP commands into a text file and tell the computer to read them and run them. While you're at it, tell the computer to store the responses from the remote system in a text file. And whatever you do, don't let the script read those responses, determine if an FTP command succeeded or failed, and continue accordingly, as a human would.

It would help if the wienies who design this junk would add some useful features to FTP, such as the ability to check a return code and to make decisions accordingly. But I'm not holding my breath. Academicians are too busy publishing (to keep from perishing) and applying for grants.

Seeing as we're saddled with crippleware, let's do the best we can do. One of the most common reasons FTP fails is that the remote server is down. Use the Verify TCP/IP Connection (PING or VFYTCPCNN) command to determine whether the server is up or not. This is really easy on my robust System i computer, because some practical someone at IBM thoughtfully provided a way for PING to send an escape message. It's in the second positional value of the MSGMODE parameter. (This is not your standard ping.)

In the following code example, the PING command tests to see if the server is up. If the PING fails, the system sends escape message TPC3210.

   dcl  &Server     *char    50
   dcl  &ServerIsUp *lgl

   chgvar     &ServerIsUp   '1'
   ping       rmtsys(&Server) msgmode(*quiet *escape)
   monmsg     tcp0000 exec(chgvar &ServerIsUp '0')

   if (*not &ServerIsUp) do
      /* whatever */

   clrpfm     ftplog   mbr(SomeMbr)

   ovrdbf     file(input)  tofile(ftpscripts) mbr(SomeMbr)
   ovrdbf     file(output) tofile(ftplog)     mbr(SomeMbr)
   ftp        rmtsys(&Server)
   dltovr     *all
   monmsg     cpf0000

I look forward to the day when everybody uses Unix. Instead of having just a few IT people at the factory, we'll need an army, and that means we'll all have jobs. Yes, Unix is truly the full-employment operating system.

                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot

Sponsored By

Do you need area code information?
Do you need ZIP Code information?
Do you need ZIP+4 information?
Do you need city name information?
Do you need county information?
Do you need a nearest dealer locator system?

We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

Just call us and we'll arrange for 30 days FREE use of either

WorksRight Software, Inc.
Phone: 601-856-8337
Fax: 601-856-9432
E-mail: software@worksright.com
Web site: www.worksright.com

Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

VAULT400:  Securely archive data with Instant Back-Up & 24x7 Recovery
Bsafe:  Enterprise Security for System i and Linux Systems
COMMON:  Join us at the 2007 conference, April 29 May 3, in Anaheim, California

IT Jungle Store Top Book Picks

The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket Developers' Guide: List Price, $59.00
The iSeries Pocket SQL Guide: List Price, $59.00
The iSeries Pocket Query Guide: List Price, $49.00
The iSeries Pocket WebFacing Primer: List Price, $39.00
Migrating to WebSphere Express for iSeries: List Price, $49.00
iSeries Express Web Implementer's Guide: List Price, $59.00
Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
WebFacing Application Design and Development Guide: List Price, $55.00
Can the AS/400 Survive IBM?: List Price, $49.00
The All-Everything Machine: List Price, $29.95
Chip Wars: List Price, $29.95


The Four Hundred
Next Up on the System i5: Native GNU g++ and IBM XL C/C++

WDSc V7.0: Componentization of Advanced Edition Is Not Enough

Gartner Says It Was "All Over" the Virtualization Effect

Kronos To Be Taken Private Through a $1.8 Billion Buyout

The Linux Beacon
Intel Shows Off Future Penryn and Nehalem Chip Designs

Cornerstones Laid for the Linux Foundation

Gartner Says It Was "All Over" the Virtualization Effect

Revenue Up, But Profits Take a Hit at Red Hat in Q4

Four Hundred Stuff
CYBRA Finds the 'Edge' for Native i5/OS RFID Software

Lakeview Adds More Autonomics to MIMIX

Thoughts on the Coexistence of Full Test Automation and Manual Testing

Help/Systems Boosts Graphics with Robot/NETWORK V10

Big Iron
IDC Chops Server Forecasts Thanks to Virtualization, Multicore Chips

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
March 31, 2007: Volume 9, Number 13

March 24, 2007: Volume 9, Number 12

March 17, 2007: Volume 9, Number 11

March 10, 2007: Volume 9, Number 10

March 3, 2007: Volume 9, Number 9

February 24, 2007: Volume 9, Number 8

The Windows Observer
Microsoft Ships Operations Manager '07, Taps EMC for Network Monitoring

Windows Vista Sales Are Hot, Hot, Hot! Microsoft Says

Oracle Sues SAP Over 'Corporate Theft on a Grand Scale'

NEC, Stratus Preview Fault Tolerant Server with Quad Cores

The Unix Guardian
Sun Breaks Sparc Unit Free Again

Gartner Says It Was "All Over" the Virtualization Effect

Oracle Sues SAP Over 'Corporate Theft on a Grand Scale'

As I See It: Workplace Heaven

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar


WorksRight Software

FTP Means 'First Try Pinging'

Improving Upon WDSC's Table View

Admin Alert: Graphically Moving i5/OS Objects with OpsNav

Four Hundred Guru


From the IT Jungle Forums
Command line question

Data Structure Array(SORTING)

Compare Source and Object Timestamps

Embedded SQL intermittently causing problems


Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement