Page 1 of 1 1
Topic Options
#1133 - 99/12/08 06:39 PM Who ran the script and when?
Anonymous
Unregistered


I am using logon scripts on a NT 4.0 server. I would like to be able to have the script wright to a .txt file on the server each time it is run giving me information like USERNAME, IPADDRESS, COMPUTERNAME, TIME.

Dose anybody know how to do this?

Brett

Top
#1134 - 99/12/09 01:13 AM Re: Who ran the script and when?
Anonymous
Unregistered


Goodmorning Brett,

I the logon-script I use, the followimg lines appends a line to the CheckUser.csv file (a Microsoft Excel Comma Separated Values File) each time a user logs on to their domain.

$FLServer="your server"

OPEN(1,"\\$FLServer\log$\CheckUser.csv",5)
$UserInfo=@WKSTA+","+"@IPADDRESS0"+","+@USERID+","+@DATE+","+@TIME+CHR(13)+CHR(10)
WRITELINE(1,"$UserInfo")
CLOSE(1)

The users should have change rights on the share log$ and the directory on the fileserver $FLServer.

The Information appended to the CheckUser.csv file is a single line existing of; Hostname, 1e IPAddress, UserID, Date and time of their current logon.

I hope this was of some assistance to you..??

Greetings,

Fabian.

Top
#1135 - 99/12/09 08:03 AM Re: Who ran the script and when?
Anonymous
Unregistered


Hi All...

As an addition to the script parts above, I used the $IPNOSPACES part to log the IPAddresses as well, and the $LoggonFileName is the file to log the info to, where a new filename is used every day automatically.
Yes the stuff works on both WNT and W95 clients and IS Y2K ! :-)

Regards,

Marc

$LogServer="NLNAV010"
$IPNOSPACES=(LTRIM(SUBSTR(@IPAddress0,1,3)))+"."+(LTRIM(SUBSTR(@IPAddress0,5,3)))+"."+
(LTRIM(SUBSTR(@IPAddress0,9,3)))+"."+(LTRIM(SUBSTR(@IPAddress0,13,3)))
$LoggingFileName="\\" + $LogServer + "\INV$\" + SUBSTR(@DATE,1,4) + SUBSTR(@DATE,6,2) + SUBSTR(@DATE,9,2) + ".CSV"

------------------
M.A.C. Duiker (Marc)
Migration Specialist (MCSE)
Marc.AC.Duiker@ici.com
[img]https://partnering.one.microsoft.com/SecureImages/mcp_c.gif[/img]

Top
#1136 - 99/12/09 10:17 AM Re: Who ran the script and when?
Anonymous
Unregistered


Thanks for the help. Here is a copy of what I ended up with.

; -----------------------------------
; LOGFILE ENTRY
; -----------------------------------

$FLServer="CENTRALPDC"
$IPNOSPACES=(LTRIM(SUBSTR(@IPAddress0,1,3)))+"."+(LTRIM(SUBSTR(@IPAddress0,5,3)))+"."+(LTRIM(SUBSTR(@IPAddress0,9,3)))+"."+(LTRIM(SUBSTR(@IP Address0,13,3)))
$LoggingFileName="\\" + $FLServer + "\log$\" + SUBSTR(@DATE,1,4) + SUBSTR(@DATE,6,2) + SUBSTR(@DATE,9,2) + ".CSV"
$UserInfo=@WKSTA+","+"$IPNOSPACES"+","+@USERID+","+@DATE+","+@TIME+CHR(13)+CHR(10)
OPEN(1,"$LoggingFileName",5)
WRITELINE(1,"$UserInfo")
CLOSE(1)

Thanks again,

Brett

Top
#1137 - 99/12/15 05:55 AM Re: Who ran the script and when?
Anonymous
Unregistered


Just as a matter of interest, @IPAddress returnes dots in the IP Address so you can use the following statement, which is a bit shorter and easier to read.

$IPNOSPACES=(LTRIM(SUBSTR(@IPAddress0,1,4)))+(LTRIM(SUBSTR(@IPAddress0,5,4)))+(LTRIM(SUBSTR(@IPAddress0,9,4)))+(LTRIM(SUBSTR(@IPAddress0,13, 3)))

Regards,
Les

Top
#1138 - 99/12/20 08:37 PM Re: Who ran the script and when?
Anonymous
Unregistered


I went down this road awhile back and what I discovered was that a flat format in your csv files does not lend well towards importing them into an ever-changing database. What you need is a key which is defined for every attribute, then eventually when you have all your .csv files collected you can dump the contents of them into a single table and run a cross-tab query (in access) to have the columns generated.

I've got the whole thing working, ..my csv's are automatically copied to the local domain server, then a service on the server fires the csv off to the central server over a WAN, then this csv file is gobbled up by the main database. It's actually pretty bitchin once you get it all going. Here's the part that you should pay attention to now before you get too far down the road (if you plan on using the information in a dynamic database down the road).. My export code looks like this:


(note that some of the items default gateway and adapters in my script are calculated by other routines besides @ADDRESS.. because kixtart doesn't know what to do in machines with more than one adapter)

;-----------------------------------------------------------------
; SUBROUTINE: export_data
; Exports all information variables to a comma delimited text file which
; is copied to the domain's management server then processed into a database
;-----------------------------------------------------------------
:export_data

DIM rtn
DIM n
DIM export_file

$export_file = $logfile_directory + "\" + $physical_mac + ".csv"

del "$logfile_directory\*.csv"
;del "$export_file"
$rtn = open(10, "$export_file", 5)
if $rtn = 0
; Newline
$n = chr(13) + chr(10)

$rtn = writeline(10, '"$physical_mac","comp_name","$comp_name"$n')
$rtn = writeline(10, '"$physical_mac","user_id","$user_id"$n')
$rtn = writeline(10, '"$physical_mac","asset_number","$asset_number"$n')
$rtn = writeline(10, '"$physical_mac","os","$os"$n')
$rtn = writeline(10, '"$physical_mac","host_domain","$host_domain"$n')
$rtn = writeline(10, '"$physical_mac","logon_domain","$logon_domain"$n')
$rtn = writeline(10, '"$physical_mac","logon_server","$logon_server"$n')
$rtn = writeline(10, '"$physical_mac","ip_address","$host_ip_addr"$n')
$rtn = writeline(10, '"$physical_mac","def_gateway","$def_gateway"$n')
$rtn = writeline(10, '"$physical_mac","logon_date","$logon_date"$n')
$rtn = writeline(10, '"$physical_mac","logon_time","$logon_time"$n')
$rtn = writeline(10, '"$physical_mac","user_name","$user_name"$n')
$rtn = writeline(10, '"$physical_mac","user_priv","$user_priv"$n')
$rtn = writeline(10, '"$physical_mac","av_inst","$av9x_installed"$n')
$rtn = writeline(10, '"$physical_mac","np_ver","$np_version"$n')
$rtn = writeline(10, '"$physical_mac","av_dom","$av_dom_loc"$n')
$rtn = writeline(10, '"$physical_mac","av_err","$av_dom_err"$n')
$rtn = writeline(10, '"$physical_mac","aw_inst","$aw9x_installed"$n')
$rtn = writeline(10, '"$physical_mac","win_mac","$mac"$n')

$rtn = writeline(10, '"$physical_mac","total_dev","$total_dev"$n')
$rtn = writeline(10, '"$physical_mac","total_ppp","$total_ppp"$n')
$rtn = writeline(10, '"$physical_mac","total_aol","$total_aol"$n')

$rtn = writeline(10, '"$physical_mac","msnet_ver","$msnet_ver"$n')
$rtn = writeline(10, '"$physical_mac","kix_ver","$kix_ver"$n')
$rtn = writeline(10, '"$physical_mac","net_ver","$net_ver"$n')
$rtn = writeline(10, '"$physical_mac","windir","$windir"$n')

$rtn = writeline(10, '"$physical_mac","vs_ver","$vs_ver"$n')
$rtn = writeline(10, '"$physical_mac","sdat_ver","$sdat_ver"$n')

$rtn = writeline(10, '"$physical_mac","user_profiles","$user_profiles"$n')
$rtn = writeline(10, '"$physical_mac","loans_mode","$loans_mode"$n')

$rtn = close(10)


; copy the infofile to the tagfiles share
? "[Copying data export: $export_file to \\$inventory_server\$tagfile_share]" ?
copy "$export_file" "\\$inventory_server\$tagfile_share" /h
If @ERROR <> 0
"Error: while copying file" $export_file ?
"@SERROR" ?
Endif
Else
? "Export_file could not be written: " $export_file ?
"Please contact the MIS" ?
"Error: @SERROR" ?
Exit
Endif
Return

------------------
K Torkelson
Sys Admin Analyst
ktorkelson@providentfunding.com


Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 36 anonymous users online.
Newest Members
TMcKenzie, dwsykes, zainlait, OgeccuT, raka74
17425 Registered Users

Generated in 0.03 seconds in which 0.01 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