Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Introduction to QShell: Administer Java applications

When it comes to running more advanced or more automated administration tasks, QShell offers the power you need.

What are your options for administering Java applications?

The good news is IBM has provided more than one way to do most of the administrative tasks you need for Java applications. Some of them can just help manage files; others do much more. Most of us probably use more than one to manage applications.

The list of tools with administration support includes the following:

* QShell: full "Unix like" command shell for running commands, creating automated scripts, testing applications

* Windows browser with mapped network drives to the IFS with Net Server running: allows "drag & drop" management of files in IFS

* FTP: allows options to manage files in IFS and QSYS library system using FTP commands

* WebSphere Studio: contains application file management services including mapping URLs for deployment using the Windows file system or FTP

* WebSphere tools for WebSphere applications: the new ANT builder tool in version 4.0, the Java admin console, WebSphere Control Program language, XML

* some commands on the iSeries, including
-- WRKLNK -- manage directories, files, authority etc in IFS
-- CPYTOSTMF, CPYFRMSTMF -- to move a source file to or from IFS
-- CPYTOIMPF, CPYFRMIMPF -- to copy data from a table to an ascii, delimited file in IFS
-- CPY -- to copy files in IFS
-- CHGAUT -- to change authority on IFS objects

* ET/400 (Enterprise Toolkit for AS/400): part of VisualAge for Java, the toolkit makes it easy for batch Java applications to: export Java classes to IFS, compile Java classes on the iSeries (optimization with the Java transformer), running a batch Java application, invoking the remote debugger for a batch Java application

What is QShell?

"The green screen command line" for managing Java applications and resources on the iSeries IFS system. Yes, completely different in terms of commands BUT conceptually very much like the standard QCMD program (your 5250 command line) you all know and love (?) for running CL commands and setting up your runtime environment for your applications. Like command entry, QShell provides a scrollable terminal window to run utility commands and view results.

QShell goes farther than QCMD. Where QCMD runs only CL commands interactively or programs, QShell is a full application shell that allows you to do the following: run QShell utilities (like CL commands), have multiple threads of execution, set the environment dynamically and create powerful, dynamic scripts that integrate Java beans and are easily reusable for many applications.

The QShell application can read input from many sources, interactively interpret the commands read, run the commands, use both Java and OS/400 resources and output results to many sources. Input and output to QShell can come from the file system or the pipes as well as the command line. This is a BIG plus over QCMD. You don't have to "key" everything in. When you create anything useful you can save it easily to a text file anywhere. It even lets you create expressions with substitution variables and evaluation so your scripts can be VERY dynamic.

Not only can you create shell scripts, but you can also extend the QShell environment with your own utilities.

To start QShell from a 5250 command line, enter STRQSH or QSH.
To exit QShell, press F3 or type exit.

At startup, QShell runs an initial set of commands in order from the following sources:
* from the file /etc/profile if it exists.
* from the file .profile in the user's home directory if it exists.
* from the file specified by the expansion of the ENV variable if it exists.

Who needs QShell?

For just setting up and deploying applications, related classes and resources the easy-to-use GUI tools of choice are WebSphere Studio, ET/400, the WebSphere Java console and the Windows browser. They are all reasonably easy to use and have useful wizards and reasonable online help.

Realistically, Java administrators (in-house or third-party) need access to QShell at some point to do some more advanced or more automated administration tasks for many application scenarios. In addition, as your skills grow, you may want to leverage the greater power QShell offers than some of the other, easier to use utilities.

What kinds of tasks can we use it for?

Often, QShell is used for the following:

  • creating directory structures in IFS
  • managing authority to directories and files for groups
  • easily copying files in IFS or QSYS library system
  • finding files by name across many directories
  • searching for any text string in any number of files with one command: grep (Did you hard code a user id into your application and need to find where it is?)
  • editing stream files in IFS with the new sed command
  • setting Java job environments with env and export
  • testing Java applications interactively
  • using ajar or jar to archive and restore applications or directory structures to a jar or zip file

Is QShell easy to learn?

Is all this easy to learn? No. Unless you are used to Unix shells that offer similar services, the average iSeries developer who knows CL will find this a less-friendly environment to learn. In its "pure" approach to a Unix shell, IBM has not provided a simple F1 help equivalent like you have on the green screen to see and prompt the QShell utilities. As a result, most of you don't bother with QShell if you have an alternative (see the easier ones listed below). That's good and bad. The other administrative options below often are easier to use but lack the powerful productivity and automation available in QShell scripts. This is much like comparing running CL commands individually from the command line vs. creating your own "smart" CL command that automates tasks for a variety of scenarios. For individuals who will do significant administration (surprise -- in your company that could be you.), learning QShell may be useful in the long run.

The QShell console DOES nicely list the available command keys in the shell most of which are very useful to you (F9 -- repeat an earlier command, etc).

To see what utilities are available in QShell

In the absence of the easy to use F1 key to see the complete list of utilities, enter the following:

ls /usr/bin

That quickly lists all the utilities included in QShell that you can call.

To see what options are available for a specific utility, usually you can enter ?h as follows. This shows the options for the list utility.

> ls -h                  
 ls: 001-3015 usage: ls [-ACFLRTacdfgilorstu1] [file ...]      

This isn't enough help to learn a command, only to quickly see the syntax and options. Typical green screen help provides enough information in many cases to learn a command. Here, use the QShell manual to get the information to understand what the command does and how it works. The QShell manual is available as a pdf file for download from the iSeries information center.

QShell supports io redirection to and from files

Here's an example of reading a command from a file instead of the console. The < operator directs the shell to read the command from the input file zu_lsin.txt.

ls < zu_lsin.txt            

 ShowClassForName.class   ShowSystemProperties.class  
 ShowClassForName.java   ShowSystemProperties.java  
 ShowClassPath.class    URLCheck.class     
 ShowClassPath.java    showJavaCmds.txt    
 ShowLocalHost.class    z_usrbin.txt     
 ShowLocalHost.java    zu_lsin.txt      

The contents of zu_lsin.txt are

ls -l /tmp/java 

To redirect output from a command to a file in IFS, the following usually works:

> ls > zo_lsout.txt  

The command above listed the contents of the current directory to a file.

Printing the output file to the console shows:

> pr -l 45 zo_lsout.txt       
 Oct 27 10:58 2001 zo_lsout.txt Page 1   

Some commonly used QShell commands in V5R1

ajar: archiving and restoring application files, directories to zip or jar files

chmod: set security authorization for resources to specific users or groups

cmp: compare the contents of 2 files (primitive version control ..)

compress: compress a file

cp: copy files or directory trees

echo: echo command output to the console (STDOUT)

env: show, set environment variables for the Java job environment ( like a JOBD++)

expr: evaluate arguments as an expression

file: return a type description for a file

find: find files using a name expression across the file system

grep: search for strings in any file across the file system

ls: list the contents of the specified directory

mkdir: create a new directory

mv: move files

od: dump an object to an output target

pr: print a default report on any text file

pwdx: show the current directory

rm: remove a file

rmdir: remove a directory

sed: simple text editor for a stream file

sort: sort, merge or sequence text files

split: split a file into parts at an offset

system: run a system command

test: evaluate an expression on file(s)

uncompress: uncompress files

xargs: construct argument lists and invoke a utility

In addition, all the JSDK utilities for Java (javac, javap, jar, javakey, keytool, policytool, etc) are available in QShell along with basic commands to manage your LDAP directory.

Now you can effectively manage your Java job environment in one place. (Compare that with the limited support for managing Java resources with CL commands?)

Remember the "easier" GUI options for administration first. If you don't administer applications often, those are easier to use. QShell is more productive, but it requires higher skills. The GUI options work well except in remote dial-up access scenarios where QShell is preferred.

Good luck learning QShell.

About the authors: Jim Mason is president of Cape Cod Bay Systems, and he writes, consults, teaches, designs and develops AS/400 Web applications using Java, WebSphere, DB2, Lotus Domino and the WebSphere Development Tools for AS/400. Dave Slater is World Wide Market Manager of AS/400 Application Development at IBM Canada.


Do you have questions about WebSphere and Web development? Post it in our new .26RlaSVDeTg^1@.ee84637>WebSphere/Web Development Discussion Forum. Here you'll get advice from our site experts who monitor the forum, as well as ideas and suggestions from other search400 members.

You may also read the Web development advice our experts have given in our Ask the Expert section.


Best Web Links on Web Development

Featured Topic: Web Development

Have a WebSphere tip of your own? Send it in. You could win a great prize.

Dig Deeper on Web Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.