• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Be Sure Qshell Accesses the Right IFS Data

    November 2, 2005 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


    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    WorksRight Software

    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 ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Cyberscience Unveils Reporting Tool for iSeries Apps Infor’s Owners Gobble Up Geac for $1 Billion

    Leave a Reply Cancel reply

Volume 5, Number 41 -- November 2, 2005
THIS ISSUE
SPONSORED BY:

T.L. Ashford
WorksRight Software
Profound Logic Software

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

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle