#169758 - 2006-10-23 03:02 PM
RedirectOutput screen and log file?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Hi,
I have had a search to see if I can find a way of outputting my logon script to a file. I found RedirectOutput which works fine except that I want it to redirect the output to a file as well as display it on screen. Is this possible?
Thanks,
Lee.
|
|
Top
|
|
|
|
#169760 - 2006-10-23 03:21 PM
Re: RedirectOutput screen and log file?
|
Björn
Korg Regular
   
Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
|
Mart, couldn't you do something like Code:
;just a suggestion - not tried or anything (just typed ;) ;EDIT quick and dirty way added to throw out a error-return
WriteAndDisplay('computername is something like: ' +@WKSTA )
Function WriteAndDisplay($entry) dim $rc,$freefilehandler $freefilehandler=FreeFileHandle() $rc=Open($freefilehandler,"d:\temp\somefile.txt",5) ?'$entry' $rc=WriteLine($freefilehandler,$entry) $rc=Close($freefilehandler) exit @error EndFunction
|
|
Top
|
|
|
|
#169762 - 2006-10-23 04:29 PM
Re: RedirectOutput screen and log file?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Excellent thanks, why didnt I think of that! 
I have found a small problem which is not directly related to this thread so I will start another. I will return here to paste 2 functions which I created from your suggestions which may help others.
L.
|
|
Top
|
|
|
|
#169763 - 2006-10-23 04:47 PM
Re: RedirectOutput screen and log file?
|
Cavester
Fresh Scripter
Registered: 2006-10-17
Posts: 18
|
Ok, just for that sake of others who may read this...
Code:
Function WriteNewLineAndDisplay($entry) WriteAndDisplay(@CRLF + $entry) EndFunction
Function WriteAndDisplay($entry) $entry
DIM $freefilehandler $freefilehandler = FreeFileHandle() DIM $rc $rc = Open($freefilehandler, @STARTDIR + "\Logs\" + @WKSTA + "-" + @USERID + ".log", 5) $rc = WriteLine($freefilehandler, $entry) $rc = Close($freefilehandler) EndFunction
You can also handle file errors depending upon what you want to do, I don't care so havn't worried about it.
L.
|
|
Top
|
|
|
|
#169766 - 2006-10-23 05:25 PM
Re: RedirectOutput screen and log file?
|
Björn
Korg Regular
   
Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
|
Geebus. I give up. we did the same thing - only I made a booboo-udf out of it. man, I really need to sleep more then 1,5h if I am supposed to get speaking/writing correct
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 271 anonymous users online.
|
|
|