You Can View User Feedback To This Tip
I had a hurdle in one of my projects to list
the
contents of an IFS directory -- in the root system.
The solutions I found on
the Internet were all oriented to using C function, which is interesting, but was not feasible to use as the client had
restricted the development
language to ILE RPG and CLLE. So through a little
bit of typical 'fiddling
around', I found this method. (I don't think its a
first, but I found it out
on my own all the same.) Here's how I did it:
- Listfile has to be created with the CRTPF command
without a DDS, the
length of the record depends on the maximum possible
length of the filename
in the IFS dir.
- QSH needs to be installed.
On execution of this command, which is nothing but
an output redirection,
the file listfile is populated with the filenames of
the files in IFS.
DCL VAR(&LSCOMMAND) TYPE(*CHAR)
LEN(200)
DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
CHGVAR VAR(&LSCOMMAND) VALUE('LS /dir1/dir2/ > +
/QSYS.LIB/' *TCAT &LIBRARY *TCAT +
'.LIB/listfile.FILE/listfile.MBR')
QSH CMD(&LSCOMMAND)
USER FEEDBACK TO THIS TIP
- If you do not have QSHELL installed, then you probably do have FTP installed. Then you still can see what is in the IFS... use FTP to your local box using the reserved loopback IP address 127.0.0.1
Here's how to do it:
The FTP command "DIR" will generate a file your RPG programs can read.
Code: Your CL source should perform a
CHGCURLIB &LIB
so you know where the file will be put when generated.
You then OPEN an FTP connection using FTP source. The IP address that you open is
FTP RMTSYS('127.0.0.1')
and your FTP source should look like:
user password
DIR /dir1 (DISK
CLOSE
QUIT
You can then write an RPG program to read the disk file created in your &LIB called DIROUTPUT. This is a more portable solution and the output is great for an RPG subfile, which lets users pick which uploaded file they wish to process. John Voris
==================================
MORE INFORMATION ON THIS TOPIC
==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.