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

x
?
Solved

AS400 scan all files / libraries for string

Posted on 2008-11-17
6
Medium Priority
?
5,398 Views
Last Modified: 2013-12-06
In preparation for a softare upgrade, I need to search all files / libraries on my AS400 for a certain string.  This string could be contained in CL and / or RPG programs.  I used STRPDM  to scan and I got some results however, I could not scan the entire AS/400 as I need to (unless I am using the utility incorrectly?!)  I had to qualify a file and library before it could scan.  What is the best way to determine every instance where this string is found?
0
Comment
Question by:cosmit
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:dude02
ID: 22979409
This is a great website that I keep on hand just in case I have to find something on my iSeries.

http://krypton.mnsu.edu/~j3gum/web/as400/intref.html

I hope this helps.
0
 

Author Comment

by:cosmit
ID: 22979550
Thanks for the great reference material dude02.  Unfortunately, it did not help my current situation.  It is great material though.
0
 
LVL 4

Expert Comment

by:dude02
ID: 22979817
You can use FNDSTRPDM command to search out strings.

I hope this helps.
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 

Author Comment

by:cosmit
ID: 22984023
I tried the FNDSTRPDM command but it requires you to specify a file and a library list.  I want to search ALL files in ALL libraries so this won't do the trick.

Any other suggestions?
0
 
LVL 36

Accepted Solution

by:
Gary Patterson earned 2000 total points
ID: 22988967
This is a bit tricky if you aren't used to Unix-style commands on the AS/400, but you can use the Qshell commands to do what you want.  Note that this requires that you have Qshell installed.  It is a free, optionally-installable component of the operating system.  Just type "QSH" at the command line to see if it is installed.  If it isn't, ask your sysadmin to install it for you.

First, dump a list of all physical files in the system to an outfile.  You may not see files that you don't hae rights to, so you probably want to run this whole process under a profile with *ALLOBJ authority.  

Note that this outfile will contain all data files and all source files in the system.

DSPFD *ALL/*ALL *PF OUTFILE(mylib/allfiles)
Then execute a Qshell command string similar to the following.  This can take a LONG time to run, depending on the number of members being searched, and you should probably run it in batch.  

There are several ways to start a Qshell command:

1) Interactively enter 'QSH" and press enter for a terminal-session style interactive session.
2) Prompt the QSH command and enter the Qshell command string in the paramater provided.  This enables you to run Qshell commands from CL, for example.
3) Use SBMJOB to execute the QSH command, containing a Qshell command string, in batch.

db2 "SELECT '/QSYS.LIB/' || trim(MBLIB) || '.LIB/' || trim(MBFILE) || '.FILE/' || trim(MBNAME) || '.MBR' FROM mylib.allfiles WHERE mbseu2='CLP'" | xargs grep '172.' > /grep.txt  

1) The "db2" command runs an SQL query over the "allfiles" table you created above, and creates a list of source members to search in IFS format (//QSYS.LIB/somelib.LIB/file.FILE/member.MBR).  This example just selects members with the Source Attribute set to CLP.  If you want to search other members, you will need to modify the query a bit.  Instead of listing all of the possible source member types, there is a file attribute that indicates if the file is a Data file or a Source file.  You could just use that in place of the mbseu2 clause.  I'm not on the corporate network right now so I can't get you the field name, but if you look at the fields in the "allfiles" file, you should see it.

2) The "|" (pipe) symbol redirects this list of members into the "xargs" command.  Xargs allows you to take a list that is generated in one command and pass it to another command that cannot accept an arbitrarily-long list of parameters.

3) "grep" searches each member for the given string, and the ">" symbol redirects the list of members where the string "172." is found to a file called "grep.txt" in the root of the IFS.

Note that grep can take a regular expression, and has lots of options, so the search can be extremely complex.  Grep is a common Linux and Unix command, and you can find examples of search syntax at thousands of sites.  Search for "grep", "grep tutorial", and "regular expressions".

You can find more information on the IBM Qshell environament and related Qshell commands at:

http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzahz/intro.htm

- Gary Patterson
0
 

Author Closing Comment

by:cosmit
ID: 31517597
Once again you came through -- Thanks!!!
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello I read in a discussion about a person who configured a very simple mirror RAID with two hard drives; the system and data were on the same partition. He asked how to repair the system as it was not booting up anymore. In his case running …
Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question