as/400 command help

Who is Participating?
JBart_17Connect With a Mentor Commented:
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.
tliottaConnect With a Mentor Commented:

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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.


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.

xaviercscConnect With a Mentor Commented:
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("");

                       // 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("");

                       // 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");

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.