delete records from a directory with IFS root using CL

5 pts.
Tags:
CL
IFS
Timestamp
How to delete records from a directory with IFS root using CL based on the timestamp of the records.
ASKED: July 24, 2008  6:55 AM
UPDATED: May 6, 2010  7:31 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

Do you mean delete <b>files</b> from the IFS based on timestamp? Or do you mean delete records from a file in the IFS?

Regards,

Martin Gilbert.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • mcl
    Next question is are you familiar with UNIX commands? You can manipulate files in the IFS using QSHELL commands - which are basically UNIX. (or UNIX-like) For example you can get a directory listing and redirect it to a file in QSYS using a command like
    ls - l ifspath > qsyspath
    
    where ifspath is formatted like dirname/dirname and qsyspath is formatted like qsys.lib/libname.lib/filename.fil/mbrname.mbr Put the whole thing in a variable like &SHELCMD and then you execute it in CL using
    QSC CMD(&SHELCMD) 
    
    Of course, then you have to parse the resulting file and determine what IFS files you need to change. If it's individual records you are looking at, it gets more complicated. You can use the CPYFRMSTMF command to copy an IFS file to a QSYS file, modify the file as needed and then use CPYTOSTMF to put it back. Regards Mike
    2,740 pointsBadges:
    report
  • mcl
    Oh.. that should be QSH CMD(&SHELCMD) not QSC.. (too many fingers....) Regards Mike
    2,740 pointsBadges:
    report
  • Anks
    I do not have the idea of UNIX. Can we do this using CL commands??
    15 pointsBadges:
    report
  • Cwc
    You could create an RPG program which uses some of the C runtime library functions (lstat, opendir, readdir, and closedir) to get a list of the files in the specified IFS directory, which could direct its output to a file. You could then create a command for that program that could be initiated from your CL. (I downloaded a utility for this a while back, IFS Tools, that was created by Peter Connell. I don't have the link anymore of where I got it, but I bet you could search and find it or something similar.) Then you could read that output file in your CL program, determine which files you want to delete, and use the DEL command to delete the specific files.
    4,290 pointsBadges:
    report
  • TomLiotta
    Can we do this using CL commands?? If you are running V5R4 or later, yes. Then you just write your CL like it was a C program or ILE RPG or COBOL. Of course, if you're going to try to do that, the programming will be much easier in C or RPG, so why do it in CL? Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following