Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 866
  • Last Modified:

as/400 command help

3 Solutions
but you really should but in a library name or a Object type or you will get way more results than you know what to do with.

When I enter LIST on a Windows 2000 command line, I get a "'list' is not recognized as an internal or external command, operable program or batch file." error. A quick look at a list of Win XP commands doesn't show "LIST" as a valid command.

So, I assume you have something specific in mind.

The WRKOBJ command is useful for listing objects in the native database file system, as noted above. The WRKLNK command is useful for listing directories and streamfiles from a standard command line.

If you're working in one of the various Unix-like shells, the standard ls utility works pretty much like it does anywhere else.

Can you clarify what you need?

sh292Author Commented:
Actually i have to list the files in as/400 directory from my java code ...fow windows we use List command to list the files in a given directory ..wht can i use in as/400
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


It's now less clear... your java for listing contents of a directory should run the same on an AS/400 as it does under Windows. However, the "List command" isn't familiar to me.

Can you supply a snippet of java that demonstrates using "LIST"?

To see the contents of a directory in the IFS of the 400 use the command WRKLNK.  Specifically, you'll need to state the path to the directory you want to view the contents of.  For example, I have a series of sub-directories and I want to see the contents of the files in one of these.  To do this, I use the command:

WRKLNK '/insite/Outbound/999983/*'

Note the tic marks (single apostrophes) around the directory path.  Also note the /* at the end of the last directory name.  That's important or else you'll just get the last directory and have to select an option to view the contents.

Hope this helps!

Carol York
For iseries oblects ther are many ways of doing this.  Try wrklib then option 12 i think.
The best option I filnd for looking at objects is to do a dspobjd to an outfile then querying the outfile for specifics.

The IFSFile class represents an object in the AS/400 integrated file system. You can use IFSFileInputStream, IFSFileOutputStream, and IFSRandomAccessFile to read and write to the file.

The below example shows how to list files on the AS/400. A filter object is supplied so that only directories are listed.

                       // Create the AS400 object.
     AS400 system = new AS400("mySystem.myCompany.com");

                       // Create the file object.
     IFSFile directory = new IFSFile(system, "/");

                       // Generate a list of all
                       // subdirectories in the directory.
                       // It uses the filter defined below.
     String[] DirNames = directory.list(new DirectoryFilter());

                       // Display the results.
     if (subDirNames != null)
       for (int i = 0; i < subDirNames.length; i++)
       System.out.println("No subdirectories.");

                       // Here is the filter. It keeps
                       // directories and discards files.
                       // The accept method is called for
                       // every directory entry in the list.
                       // If the element is a directory,
                       // 'true' is returned so the
                       // directory is returned. The results
                       // are returned in the string array
                       // returned to the list() method
                       // above.
     class DirectoryFilter implements IFSFileFilter
        public boolean accept(IFSFile file)
          return file.isDirectory();

The Java program can optionally specify match criteria when listing files in the directory. Match criteria reduce the number of files that are returned by AS/400 to the IFSFile object, which improves performance. The following example shows how to list files with extension .txt:

                       // Create the AS400 object.
     AS400 system = new AS400("mySystem.myCompany.com");

                       // Create the file object.
     IFSFile directory = new IFSFile(system, "/");

                       // Generate a list of all files with
                       // extension .txt
     String[] names = directory.list("*.txt");

                       // Display the names.
     if (names != null)
       for (int i = 0; i < names.length; i++)
       System.out.println("No .txt files");


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now