22
Fri, Nov
1 New Articles

AS/400 Finally Gets a UNIX Face

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Using Qshell, you can develop Java programs, run threaded programs, work with objects in the Integrated File System, and write scripts that run on other systems.

Starting with V3R1, the AS/400 has been adding functions based on industry standards from POSIX and X/Open. Even though the AS/400 now offers many APIs from these standards, it has been missing a UNIX-style shell interpreter and several utilities that go along with it. The shell and utilities combination provides a powerful scripting environment.

Qshell, a new feature of the AS/400 starting with V4R2, provides a UNIX-style command environment. The Qshell environment consists of two parts:

• The shell interpreter (or qsh) is a program that reads commands from an input source, interprets each command, and then runs the command by using the services of the operating system. The shell interpreter is similar to the command analyzer for CL. The Qshell Interpreter is option 30 of OS/400.

• The utilities or commands are external programs that provide additional functions and can be quite simple or very complex. The utilities are similar to CL commands. Qshell Utilities for the AS/400 (5799-XEH) is a PRPQ that includes 50 common utilities.

Background

A shell interpreter is a command line interface for working with the resources of a computer including programs, files, and devices. Every command-driven operating system has a shell interpreter. On AS/400s, the default shell interpreter is the command analyzer (or QCMD). On DOS and Windows, the command line interface is COMMAND.COM. On UNIX systems, there are many shell interpreters that have been developed over the years.

The Bourne shell (or simply sh) is the default shell that is provided with most UNIX systems. It is the oldest shell and is generally compatible across different systems. The C shell (or csh) provides a command language and syntax that is similar to the C programming language. It is a good interactive shell, but it is a weak shell for writing

scripts. The Korn shell (or ksh) is upwardly compatible with the Bourne shell, but it contains features that make it a good shell for both interactive use and writing scripts.

The shell and utilities are standardized with the POSIX 1003.2 standard. The standard is based on a 1988 version of the Korn shell. Since then, new versions of the Korn shell have been released with the last major update in 1993. There is also the Bourne Again Shell (or bash) that is based on the POSIX standard.

Qshell is the shell and utilities for the AS/400 based on the POSIX standard. It is compatible with the Bourne shell and many Korn shells. The Qshell Interpreter contains some features from the new Korn shell.

Reasons for Using Qshell

Qshell is an important addition to AS/400s for these reasons:
• Developing Java programs. The Java Development Kit (JDK), provided by Sun, includes 12 utilities for developing Java programs. The AS/400 Developer Kit for Java conforms to the Java standard, and, for that reason, these utilities are available only from Qshell. That means a Java developer can use the same utilities with the same interface on an AS/400 as they do on other systems.

• Running threaded programs. A threaded program can be developed in either Java or C by using the POSIX thread (Pthread) APIs. But a threaded program cannot start threads in an interactive job. The

Qshell command interface is implemented by using batch jobs, which can be multi-thread capable. So from the Qshell command line, you can run an interactive, threaded program.

• Working with objects in the Integrated File System (IFS). All of the utilities provided with Qshell are enabled for working with the IFS. This can make it easier to navigate in the many file systems in the IFS.

• Writing scripts that can run on other systems. Because Qshell is based on a POSIX standard, the shell scripts you write can run on other systems or scripts from other systems can be brought to the AS/400. Many new products are now providing common utilities. For example, the Directory Services option of OS/400, the Distributed Computing Environment (DCE) for AS/400 products, and the Net. Question products all provide Qshell utilities equivalent to the utilities in versions of their product for other systems. This allows a user or administrator of the product to have the same interface on different systems.

Qshell Language

The Qshell language is interpreted and is the same for both interactive use and writing scripts. The language is quite powerful and provides the following capabilities.

There are simple and compound commands. A simple command is just the name of a utility that you want to run. The shell interpreter searches for the command in the directories specified by the PATH environment variable. This is similar to the command analyzer searching the library list for a command.

The compound commands include the if-then-else conditional, case conditional, while loop, until loop, for loop, and functions. A function is a like a function or procedure from other programming languages. By using compound commands, you can write complex scripts using familiar programming constructs.

Redirections allow you to change where the input for a command comes from and where the output of the command goes. It is similar to an override in CL, but it can be much more powerful. For example, you can chain several commands together in a pipeline. This allows you to send the output from one command to the input of the next command. By using this technique, you can process the output from the first command through a sequence of other commands.

The shell interpreter also performs word expansions on its input. With a word expansion, the shell interpreter substitutes one string in the input for another string. Each word expansion is identified with a special character string. These are the expansions:

• A parameter expansion substitutes the value of a variable. A parameter expansion is specified by $(variable).

• A command substitution allows the output of a command to be substituted in place of the command name. A command substitution is specified by $(command).

• An arithmetic expansion evaluates a string as an integer arithmetic expression and substitutes its value. An arithmetic expansion is specified by $((expression)).

• A path name expansion substitutes a pattern for all of the files that match the pattern. This is like using a generic string in CL but is more powerful. A pattern is specified with the asterisk (*) to match all characters, the question mark (?) to match a single character, or brackets ([char]) to match a character class.

• A tilde expansion substitutes a tilde character with the user’s home directory. Only the Beginning Qshell provides a new environment for working with AS/400s where you can run UNIX utilities. Along with CL and Operations Navigator, it provides another interface for users on the AS/400. It also provides the base enablement for continuing to add new functions. For more information, see the Qshell Web site at www.ibm.com/as400/ developer/qshell.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: