IllegalFileName check (or Continuing on Error)

(imported topic written by tomfranken)

I’m looking for all the Java.exe files on servers. The following code works well until I get a random illegal file name:

q: ("]",computer name,pathnames of it,(if (exists version of it) then (version of it as string) else (“Unknown version”))) of descendants whose (name of it as lowercase contains “java.exe”) of folders “\Program files\Java” of drives whose (type of it = “DRIVE_FIXED” AND name of it = “C:”)

A:], , C:\Program files\Java\jre6\bin\java.exe, 6.0.450.6

A:], , C:\Program files\Java\jre7\bin\java.exe, 7.0.210.11

T:383.060 ms

q: ("]",computer name,pathnames of it,(if (exists version of it) then (version of it as string) else (“Unknown version”))) of descendants whose (name of it as lowercase contains “java.exe”) of folders “\Users” of drives whose (type of it = “DRIVE_FIXED” AND name of it = “C:”)

E:The expression could not be evaluated: class IllegalFileName

In use, I won’t restrict to “C:” and I’ll start at folder “” but this quickly throws the error. I could skip the “Users” folder on this server but I don’t know what problem the next server may have. In scripting, we generally have an “On error continue” type command. How can I continue on an error? I also don’t know what other error I may have in a folder or filename so I don’t want to write a bunch of “if not this error and if not that error…” statements for every conceivable error.

(imported comment written by Rafael Rodriguez)

pathnames of files whose (name of it as lowercase contains “java”) of folders of folders of folders of folders of folder (“c:\Program files”)

If you flip the search to the entire partition does not work. You have to refine your search.

(imported comment written by tomfranken)

Unfortunately, they go 13 folders deep. I can’t help that people have copies of copies. I need to remove all old versions. I have a bunch of legitimate installs that are 8, 9, and even 11 folders deep. The error I had will still come up.

C:\Documents and Settings<username>\My Documents\Gerry\Documents and Settings<username>\My Documents\OCIE\Installers\Install\Copy\Autn_Retina\jre\bin\java.exe

(imported comment written by martinc)

I am wondering if the better way to do this would be to run a script to dump the info to a text file and then use an analysis to collect the data from the output file. If you are trying to scan the entire file system with an analysis, you could really bog the agent down with just processing this one data point.

You could have a script the just does a “dir /b /s c:\java.exe”, then have the analysis use the path in the output file to identify the java.exe file and then get the version. Or you could have the script get the list and get the version information and then just collect that.

Martin

(imported comment written by tomfranken)

That’s what I’ve been working on. It presents it’s own problems. I was hoping to keep the whole process in TEM. I would think a scripting language would have a process to handle errors without having to write a series of if-then statements to test every object. Maybe in the next release…

(imported comment written by martinc)

Just to make sure I cover the process a bit better

  1. Create a TEM task that will run a script/command to generate an output file. In the relevance you could make the task relevant to systems that do not have the output file at all or you could additionally have it check if the file is older than some number of days, that way you can run the task again to make sure the output file is more up to date.

  2. Create an analysis that checks to see if the file exists and then return the file information. If the file does not exist, then return back something like “missing file”. You could also just make it not relevant if the file does not exist, but then you might miss systems

I strongly recommend this two step approach for what you are trying to do because of the time it takes for a file system listing to run. If this were just checking a couple folders, then I would work more on doing it all in the analysis.