Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kixtart scripting

Status
Not open for further replies.

kestrel1

Technical User
Jan 8, 2003
932
GB
I know a little bit about scripting in kixtart, but I would like some help with the following:
I am trying to write a script that will send the following information to a text file when a user logs on.
Username, local machine name & time.
The only thing is that the file would need to be appended for each user that logs on. Also would there be an issue with sharing violations if the users logon at the same time.
Do you think this is possible & if so what comands do I need to use in Kixtart.
Any help greatly appreciated.
Glyn
 
Instead of loging it to a file I would recommend logging it to a database. This would help aleviate any sharing issues.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks for that, but I still don't know how to set it up.
It looks like a long weekend trying to sort it out.
 
Go to for kix scripts (and other scripting language) examples.

I'm not sure about the logging question of whether the file will get locked if two people logon at the exact same time. I would think it would. A solution to this is to have individual log files created for each user. Then, when you want to see a report, run a batch file that generates a concatination of all of the individual log files. (note: in your script, make sure that you have logic where the script checks for an existing log file and deletes it before creating a new log file)

This is an example of the report generator:

for /f %a in ('dir /s /b /a-d') do type %a | find "++++" >>c:\report.txt

bsmith.txt would have to have text inside that has "++++" before and after for to be captured in the log.



Here is a script that will open an log and capture some of the information you want.

; Use OpenLog to create a new log
; Use EndLog to close the log
; Use LogItem before and after the routine you want to measure
; Some variables are not available under WinNT.
; SESSIONNAME variable is used when running it
; on a terminal server/citrix server

$NoTimeStamp=1

:OpenLog
; Here the logfile is created
; The computername
if "%SESSIONNAME%"=""
$logpath="\\server\errorlog$\timing\%COMPUTERNAME%-kix.txt"
else
$logpad="\\server\errorlog$\timing\%CLIENTNAME%-kix.txt"
endif
del "$logpad"
$x=Open(2, $logpad,5)

$x=LogItem("Begin Logging")
$x=LogItem("General information",$NoTimeStamp)
$x=LogItem("===================",$NoTimeStamp)
$x=LogItem("Logon server : %logonserver%",$NoTimeStamp)
$x=LogItem("Computer naam: %COMPUTERNAME%",$NoTimeStamp)
$x=LogItem("Home share : %homeshare%",$NoTimeStamp)
$x=LogItem("User : %username%@@%userdnsdomain%",$NoTimeStamp)
return

:EndLog
; Logfile is closed
$x=LogItem("End Logging")
close(2)
return

function LogItem ($ctext,optional $timestamp)
; A logitem is written to the logfile
; preceeded by the current date and time
if $timestamp=$NoTimeStamp
$ctext="@date @time"+$ctext
endif
writeline (2,$ctext+ Chr(13) + Chr(10))
endfunction

Joseph L. Poandl
MCSE 2003

If your company is in need of experts to examine technical problems/solutions, please contact (Sales@njcomputernetworks.com)
 
Thanks very much for the info. I will have a play around with this & see what I can get to work. Probably a good idea about individual text files. Only problem will be the amount of files created (over 1000 users), but hopefully once I get the script working I can sort this out.
Many thanks again.
Glyn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top