append "if exist" result to flat file

M

mdtripla

This script runs on one machine at a time and each machine needs to be
able to append to the same flat file.

I have a few examples and can append results to a flat file but need
to check for various log files in 1 location and if they exist i need
to append the result to a flat file. this is what I have in a batch
file executed via batch blitz.



+++++++++++++++++++++++++++++++++++++++

echo \\%1 >> Fix_Chk.log
if exist \\%1\Admin$\kb823980.log echo MS03-026 >> Fix_Chk.log
if exist \\%1\Admin$\kb824146.log echo MS03-039 >> Fix_Chk.log
if exist \\%1\Admin$\kb823182.log echo MS03-041 >> Fix_Chk.log
if exist \\%1\Admin$\kb826232.log echo MS03-042 >> Fix_Chk.log
if exist \\%1\Admin$\kb828035.log echo MS03-043 >> Fix_Chk.log
if exist \\%1\Admin$\kb825119.log echo MS03-044 >> Fix_Chk.log
if exist \\%1\Admin$\kb824141.log echo MS03-045 >> Fix_Chk.log
echo =================================================================
+++++++++++++++++++++++++++++++++++++++

and here is the result in the flat file

+++++++++++++++++++++++++++++++++++++++

\\NFD00030652W2K
MS03-026
MS03-039
MS03-041
MS03-042
MS03-043
MS03-044
MS03-045
=================================================================
\\NFD00030685W2K
MS03-026
MS03-039
MS03-041
MS03-042
MS03-043
MS03-044
MS03-045
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

That is the information that I want but I need it to be laid out
differently like the following example. so It can be opened in excel
for reporting.

NFD00030652W2K MS03-026 MS03-039 MS03-041 MS03-042 MS03-043 MS03-044

Any help would be great.

Thanks,
Dustin
 
R

Ray at

Did you try what I suggested in the vbscript group? Here it is again.

SET LOG=%1
if exist \\%1\Admin$\kb823980.log set log=%log% MS03-026
if exist \\%1\Admin$\kb824146.log set log=%log% MS03-039
rem etc....
ECHO %LOG%>>Fix_Chk.log

Ray at work
 
M

mdtripla

Sorry about that Ray. I can be pretty thick sometimes. The format is
perfect except when I open it in excel (the goal) and then it paces
the result in one column. I am going to look at it again and see if
you provided a solution or if you have another idea that would be
great.

Thanks again,
Dustin
 
M

mdtripla

Ray,

You are right. I changed the script from spaces to tabs and that took
care of the issue I think.

Thanks for the help,
Dustin
 
R

Ray at

Just out of curiosity, what did you use? I could have sworn that Notepad
didn't convert tabs to spaces, but when I tried it in notepad, I did not get
tabs when I executed the batch. Creating the same file in Textpad kep the
tabs. Maybe I saved with the wrong format or something in notepad. My user
error of some sort, I'm sure.

Ray at work
 
P

Phil Robyn

Ray at said:
Just out of curiosity, what did you use? I could have sworn that Notepad
didn't convert tabs to spaces, but when I tried it in notepad, I did not get
tabs when I executed the batch. Creating the same file in Textpad kep the
tabs. Maybe I saved with the wrong format or something in notepad. My user
error of some sort, I'm sure.

Ray at work

Hi, Ray:
 
R

Ray at

Hi, Ray:

Instead of <TAB>, why not just use comma as the delimiter?
THAT WAS NOT THE QUESTION, PHIL! I'm kidding!!!! I agree that commas would
be better. I was just curious about my notepad issues.

Ray at work
 
P

Phil Robyn

Ray at said:
THAT WAS NOT THE QUESTION, PHIL! I'm kidding!!!! I agree that commas would
be better. I was just curious about my notepad issues.

Ray at work

'notepad'? What is 'notepad'? ;-)
 
M

mdtripla

Ray,

I am using notepad in this case and it seems to work just fine. The
only problem now is that when opening the flat (tab delem) file the
result may not line up due to some machines missing the patches.
machine1 <tab> MS03-026 <tab> MS03-039 <tab> MS03-041 <tab> MS03-042
etc
machine2 <tab> MS03-026 <tab> MS03-041 <tab> MS03-042 <tab> MS03-045
etc

Not quite right for reporting but tons better then before

Thanks,
Dustin
 
P

Phil Robyn

mdtripla said:
Ray,

I am using notepad in this case and it seems to work just fine. The
only problem now is that when opening the flat (tab delem) file the
result may not line up due to some machines missing the patches.
machine1 <tab> MS03-026 <tab> MS03-039 <tab> MS03-041 <tab> MS03-042
etc
machine2 <tab> MS03-026 <tab> MS03-041 <tab> MS03-042 <tab> MS03-045
etc

Not quite right for reporting but tons better then before

Thanks,
Dustin

Instead of <TAB>, I would use commas as delimiters. To solve the problem
of the columns not lining up, I think I would use something like the
following (not tested):

=====begin c:\cmd\demo\FindPatches.cmd ====================
01. @echo off
02. setlocal
03. SET LOG=%1
04. for %%a in (
05. 823980.026 824146.039 823182.041 826232.042 828035.043 825119.044 824141.045
06. do (
07. if exist \\%1\Admin$\kb%%~na.log (
08. call :YES %%~xa
09. ) else (
10. call :NO
11. )
12. )
13. echo %LOG%>>Fix_Chk.log
14. goto :EOF
15. :YES
16. set num=%1
17. set num=%num:.=%
18. set LOG=%LOG%,MS03-%num%
19. goto :EOF
20. :NO
21. set LOG=%LOG%,-
22. goto :EOF
=====end c:\cmd\demo\FindPatches.cmd ====================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top