Page 1 of 1 1
Topic Options
#169758 - 2006-10-23 03:02 PM RedirectOutput screen and log file?
Cavester Offline
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
#169759 - 2006-10-23 03:07 PM Re: RedirectOutput screen and log file?
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
No.

You could do something like this if you want the info on the screen and in a file.

Code:

Break on
;
$rc = Open(1,"c:\somefile.txt", 5)
;
?"The name of this computers is: " @WKSTA
$rc = WriteLine(1,"The name of this computers is: " + @WKSTA)
;
$rc = Close(1)

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#169760 - 2006-10-23 03:21 PM Re: RedirectOutput screen and log file?
Björn Offline
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
#169761 - 2006-10-23 03:48 PM Re: RedirectOutput screen and log file?
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sure, but that is sort of the same script only difference is that it is stuffed into a function
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#169762 - 2006-10-23 04:29 PM Re: RedirectOutput screen and log file?
Cavester Offline
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 Offline
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
#169764 - 2006-10-23 04:50 PM Re: RedirectOutput screen and log file?
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
phaw, no it's not ;P it use freefilehandle as well ;P
Top
#169765 - 2006-10-23 05:00 PM Re: RedirectOutput screen and log file?
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
ROFLMAO

That why I said ....sort of the same....
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#169766 - 2006-10-23 05:25 PM Re: RedirectOutput screen and log file?
Björn Offline
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
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 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.111 seconds in which 0.076 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