Page 1 of 1 1
Topic Options
#28315 - 2002-09-03 03:34 PM Process a list of items
John A. (Tony) Kenny Offline
Lurker

Registered: 2002-08-30
Posts: 4
Can anyone tel me how to process a list of items ?
I want to create a list and then process items in the list one at a time.

I am trying to write a script to archive event logs on all of my servers. I would like to create a list with all of the server names and tehn do something like this:

get $server
BackupEventlog( "\\$server\Application" , "c:\evlogs\application.evt")
BackupEventlog( "\\$server\System" , "c:\evlogs\system.evt")
BackupEventlog( "\\$server\Security" , "c:\evlogs\security.evt")
ClearEventlog( "Application" )
ClearEventlog( "Security" )
ClearEventlog( "System" )

Any ideas ?

Also I would like to rename the archive event log using the server name and the date as part of the file name, and I haven't quite figured out how to do that either.

I am really new to kixtart. Any help would be appreciated.

Thanks

Top
#28316 - 2002-09-03 03:37 PM Re: Process a list of items
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can write all your servers to a file then use Open and ReadLine to access the names. Or you could hard code them into your script using an array then use a "for each $server in $ServerArray" syntax.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#28317 - 2002-09-03 04:34 PM Re: Process a list of items
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
you can also use a .INI file like
code:
[SERVERS]
SERVER1 = Windows 2000 Server
SERVER2 = Windows 2000 Advanced Server

Then you can read the list with
code:
$serverarray=readprofilestring('servers.ini','SERVERS','')
for each $server in $serverarray
$rc=BackupEventlog( '\\'+$server+'\Application' , 'c:\evlogs\application.evt')
$rc=BackupEventlog( '\\'+$server+'\System' , 'c:\evlogs\system.evt')
$rc=BackupEventlog( '\\'+$server+'\Security' , 'c:\evlogs\security.evt')
$rc=ClearEventlog('Application')
$rc=ClearEventlog('Security')
$rc=ClearEventlog('System')
next

You might want to consider to copy the eventlogs to a central location after the backup. However, be aware that BACKUPEVENTLOG can only create a backup on the local disk.

[ 03. September 2002, 16:34: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.131 seconds in which 0.101 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org