#1702 - 2000-02-16 10:00 AM
REDIRECTOUTPUT adds 0 to beginning of file
|
Anonymous
Anonymous
Unregistered
|
I'm trying to use the REDIRECTOUTPUT command to redirect screen output to a file. It works great except it puts a 0 at the beginning of the file (first character). Is there a way to stop the 0 from appearing in the file? I'm hoping to redirect the output to a .BAT or .REG file so the 0 would cause problems. Thanks in advance for sharing your expertise.
|
|
Top
|
|
|
|
#1703 - 2000-02-16 03:19 PM
Re: REDIRECTOUTPUT adds 0 to beginning of file
|
Anonymous
Anonymous
Unregistered
|
FYII got impatient waiting for an expert to offer advice and tried using other methods. Instead of using REDIRECTOUTPUT which wanted to post the result code 0 within the new file, I used the Open, WriteLine, Close commands. This worked great. Example: Open(1,"test.reg",5) WriteLine(1,"text"+chr(10)+chr(13)) Close(1) When the file was being written to, a 0 was posted to screen for each WriteLine command noting the success of the write. Fortunately this went to screen and not to my file.
|
|
Top
|
|
|
|
#1704 - 2000-02-16 04:35 PM
Re: REDIRECTOUTPUT adds 0 to beginning of file
|
Anonymous
Anonymous
Unregistered
|
Uslmis,You are getting the 0 because REDIRECTOUTPUT, OPEN and CLOSE are all functions which return a result code. If you don't want to see the 0, all you need to do is set use a variable to collect the result code. Example: $x = RedirectOutput("logon.log") OR $x = Open(1,"test.reg",5) $x = Close(1)
|
|
Top
|
|
|
|
#1706 - 2002-06-24 01:49 AM
Re: REDIRECTOUTPUT adds 0 to beginning of file
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
The variable $Write is being directed to the screen and hence to the file.
$Write = ReDirectOutput("\\server\share\$filename")
$Write <--- this is your problem. ", @userid, $os, $fileversion, $ieversion, @address, @DATE"
Delete the above line and should remove the "0". [ 24 June 2002, 01:49: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#1707 - 2002-06-24 01:53 AM
Re: REDIRECTOUTPUT adds 0 to beginning of file
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
jbastete, welcome to the board.
Your script - $write= get the error status value of your RedirectOutput caLL - $write show the ZERO in your file - ", ...." seems to append to previous contents. your first character is a ","-symbol.
Two versions
- RedirectOutput
code:
$write=RedirectOutput("\\server\share\"+$filename) ? ", @userid, $os, $fileversion, $ieversion, @address, @date" $write=RedirectOutput("")
or
code:
$write=RedirectOutput("\\server\share\"+$filename) ", @userid, $os, $fileversion, $ieversion, @address, @date" $write=RedirectOutput("")
code:
IF (RedirectOutput("\\server\share\"+$filename) = 0) ", @userid, $os, $fileversion, $ieversion, @address, @date" ENDIF IF RedirectOutput("") ENDIF
- Open/WriteLine/Close
IF (Open(1,"\\server\share\"+$filename) = 0) $write=WriteLine(1,", @userid, $os, $fileversion, $ieversion, @address, @date"+@crlf) IF Close(1) ENDIF ENDIF [/code]
greetings. btw: a very old topic.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|