Page 1 of 1 1
Topic Options
#49042 - 2000-02-21 08:29 AM Script RedirectOutput Error
Anonymous
Unregistered


Hello!

I'm developing my login scripts. Some days ago I had to distribute one URL to user desctops. I wrote a script (applied in attachment)
But I cannot understand, why it is not working properly. Script must write any data to a log file. But it writes only a first string.
When I run it in debug mode from a local computer, it works. From NETLOGON - fails. Can You explain,what is the difference?
What's happened?

Regards
------------CODE--------
; HelpDesk install

Global $HDLogFile, $hdmsg, $hd, $trg
$HDLogDir="\\spetntp1\log\"
$HDLogFile=$HDLogDir+LCASE(@USERID)+".log"

;
;write header to a log file
;
$hdmsg="DATE: "+@DATE+" Kix Version: "+@KIX
gosub logevt

;
;check is the source file exist in NETLOGON$
;
$hd="helpdesk.url"
if exist($hd)
$hdmsg="Source file found!"
gosub logevt
goto install
else
$hdmsg="Source file not found"
gosub logevt
exit 1
endif

:install

;
;OS - Win 95. Copy HelpDesk.URL to c:\windows\desktop and
;common desktop, if multiprofiles are switched on
;
if @INWIN=2
;write an OS type to Log File
$hdmsg="OS - Windows 95"
gosub logevt
$shpath1="c:\windows\desktop"
$shpath2="c:\windows\all users\desktop"
$trg=$shpath1+"\" + $hd
gosub copyhd
$trg=$shpath2+"\" + $hd
gosub copyhd
endif

if @INWIN=1
;write an OS type to Log File
$hdmsg="OS - WinNT"
gosub logevt
$shpath="c:\winnt\profiles\all users\desktop"
$trg=$shpath+"\" + $hd
;write shotcut to common desktop
;will not affect if user is not local admin
gosub copyhd
$shpath="c:\winnt\profiles\"+@USERID+"desktop"
$trg=$shpath+"\" + $hd
;write shotcut to user desktop
gosub copyhd
endif

;
;end script
;
exit

:copyhd
$hdmsg="Target file is "+$trg
gosub logevt
; exit from subroutine if target file exists
if exist($trg)
$hdmsg="Target file allready exists"
gosub logevt
goto endcopy
else
copy $hd $trg
endif
;check results of copying
if exist($trg)
$hdmsg="copying successful!"
gosub logevt
endif
:endcopy
return

;write message to a KIX screen and to a Log file at once
;parameter: $hdmsg - string

:logevt
? "$hdmsg"
;redirect output to a file
$rez=RedirectOutput($HDLogFile)
? @TIME+" "+$hdmsg
; redirect output back to screen
$rez=RedirectOutput("")
return
----------------------
OUTPUT

12:36:52 DATE: 2000/02/21 Kix Version: 3.62
----------------------



Top
#49043 - 2000-03-10 11:16 PM Re: Script RedirectOutput Error
Anonymous
Unregistered


On_Jon ** 3/10/2000 **

Here are several examples of redirects that work.

;;=========================================

$LogLoc="\\WGC-AUB-03\logs$\dchk\" ;share open to all RWX
;$LogLoc="%TEMP%\" ;in case the above is not set
$LogFile="D_Log.txt" ; log file name and extension

$ShoDate="@monthno/@mdayno/@year" ; for showing date in mm/dd/yyyy format ; KIX @Date
;;=========================================

;
; ----------- Check OS -------------
; check OS note: Win2K @Dos returns 5.0 Win98 4.10 and both Win95 and NTW 4.0 are 4.0.
$OSVer = @DOS
if $OSVer = ""
$OSVer = "OSVerND"
endif
$OS = "Windows NT"
if @INWIN = 2
$OS = "Win9x $OSVer"
else
$OS = "WinNT $OSVer"
endif

;
;------------ For setting test mode --------------

$dmp=""
if exist("%temp%\chkdmp")=1
$dmp=1 ; $dmp=1 means were in debug dump test mode
color w+/r
? " Running script in debug dump mode "
? " Dumping to temp\chklog.txt"
sleep 02
else
color y+/b
endif
? ""

;================== For test /debugging mode - dumps to temp\chklog.txt
if $dmp="1"
$t= RedirectOutput(%TEMP%\chklog.txt , 0 )
? ""
? "OS and version is $OS"
? "NetID is $PC_ID"
? "Log file is set to $LogFile"
? "Log location is $LogLoc"

? "System date $ShoDate at @Time"
? ""
$y=RedirectOutput("")
endif
;==================

;
;------------ Log out --------------
;
:SENDLOG
$L= RedirectOutput( "$LogLoc$LogFile" , 0 )
? "D_Check," + "@USERID,@FULLNAME,@PRIV,$OS,$ShoDate @TIME,"
sleep 01
$y=RedirectOutput("")
? ""
endif

;;=========================================


Top
Page 1 of 1 1


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

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

Generated in 0.052 seconds in which 0.024 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