Newsletters   Subscriptions  Forums  Store   Career  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 5, Number 41 -- November 2, 2005

Be Sure Qshell Accesses the Right IFS Data


by Ted Holt


Today I continue my relentless Campaign to Eradicate Unreliable Software. Just recently, I saw a real-life example of the problem of unreliability. Program A called Program B to change the library list. Program B failed, the library list did not get changed, but Program B never bothered to tell Program A about it. Program A continued running with the wrong library list. As I wrote in Proper CL Error Handling, it's imperative to catch every error and make sure that it is dealt with.

The same sort of thing can happen in Qshell scripts. If a Change Directory command fails, Qshell generates an error message, but does not halt the script. Just as Program A continued running with the wrong library list, a Qshell script can continue on its way with the wrong current directory. Here's an example.

#!/bin/qsh
cd br549
rm can*

If the current directory contains a directory named br549, everything is hunky dory, but if there is no directory named br549 in the current directory, the cd command fails, sending error message 001-0008. (Error found changing to directory br549.) The rm command removes the files whose names begin with "can" from the wrong directory.

To abort the script, use the or construction (two vertical lines) to send a non-zero return code to the caller.

cd br549 || return 5

If the cd command is successful, the return is ignored. If the cd fails, the return kicks in and sends a return code of five to the caller. It is up to the caller to check for the return code and take appropriate action.

If the error message that cd generates presents a problem, redirect it to /dev/null. Redirecting the message to /dev/null sends it to never-never land.

cd br549 2> /dev/null || return 5

You can't be too careful. If something can go wrong, assume it will, and plan for the failure.

--Ted


RELATED STORY

Proper CL Error Handling


Sponsored By
T.L. ASHFORD

BARCODE400 by T.L. Ashford is the easiest
and fastest way to create and print Compliance
Labels directly from the AS/400 and iSeries.

Ashford's comprehensive library of Compliance formats is available to Barcode400 users. AIAG labels for Ford and Motorcraft, GM, and many more are available. BARCODE400 is backed by the best Technical Support Team in the industry.

FREE Guide to Bar Code Labeling

www.tlashford.com or call 800.541.4893


Technical Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, 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.


THIS ISSUE
SPONSORED BY:

T.L. Ashford
WorksRight Software
Profound Logic Software


Four Hundred Guru

BACK ISSUES

TABLE OF
CONTENTS
Be Sure Qshell Accesses the Right IFS Data

Restricted Access to SST

Admin Alert: Hidden Secrets of the i5/OS Save Commands


The Four Hundred
iSeries Salaries Are Shaping Up to Rise 2006

IBM Identifies Hot Markets for iSeries Growth

Readers Weigh in on the Hypothetical System i5 for SMB

Mad Dog 21/21: Omission Accomplished

Four Hundred Stuff
Kronos Tackles Unscheduled Absenteeism with Labor Software

Informatica Aims to Virtualize Data with PowerCenter 8

AVR Provides a Better Alternative Than Screen Scraping, ASNA Says

Cyberscience Unveils Reporting Tool for iSeries Apps

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc. (formerly Midrange Server), 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement