I would like to write a utility which housekeeps stream files in the ifs based upon how many days ago the file was CREATED.
Does any body know an API for this (an API which is easy enough to work with 'RPG' and/or 'CL' and NOT 'C')
The DSPLNK CL command doesn't provide the creation date it would appear and the closest API I can find is QHFOPNDIR, which I have been told is for QDLS and not IFS?
Software/Hardware used:
ASKED:
April 20, 2006 9:13 PM
UPDATED:
April 26, 2006 5:34 AM
Use the UNIX shell within CLP to analise the IFS directory
Command STRQSH
This will allow you to use UNIX type commands “LS” list, “RM” remove etc (almost like “DOS” but annoyingly different).
You can redirect the output from the “unix” commands back to a physical file within your CLP.
Example:
/* Redirect output from STRQSH session to IFS file */
ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) +
VALUE(‘FILE=/IFSDirectory/LISTFILE.TXT’) +
REPLACE(*YES)
MONMSG MSGID(CPFA980)
/* Creates a Directory listing in LISTFILE.TXT in IFSDirectory */
CHGVAR VAR(&CMD) VALUE(‘LS /IFSDirectory/(files to list))
STRQSH CMD(&CMD)
MONMSG MSGID(QSH0002)
/* Copy Directory Listing from the previous step to iSeries PF QTEMP/CSPLSOUT
CPYFRMSTMF FROMSTMF(‘/IFSDirectory/LISTFILE.TXT’) +
TOMBR(‘/QSYS.LIB/QTEMP.LIB/iSeriesFile.FILE/ iSeriesFile +
.MBR’) MBROPT(*REPLACE)
MONMSG MSGID(CPFA0A9 CPFA095)
Analise the data on the iSeries and then use the RM remove unix command.
Other Unix commands may be mor apropriate.
Miles
You could also use C procedure Qp01GetAttr(). The return data structure includes a 10 digit integer variable listing the number of seconds from epoch (01/01/1970 00hh 00mm 00ss) allowing you to calculate the date/time the object was created. The procedure can be prototyped and invoked within an RPG program. Reference material on iSeries UNIX type IFS APIs can be found on the IBM InfoCenter Website.
look at this RPG tool : http://jplamontre.free.fr/AS400/DSPIFS.htm
it walks IFS, can show data inside file. In the code, there is 3 calls to the ‘stat’ api :
rc = stat (pathdirs: myStat );
rc = stat64 (pathdirs: myStat64 );
rc = statvfs(pathdirs: myStatVFS );
here is one solution to your question.