Page 1 of 1 1
Topic Options
#1702 - 2000-02-16 10:00 AM REDIRECTOUTPUT adds 0 to beginning of file
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
Unregistered


FYI

I 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
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
#1705 - 2002-06-24 12:51 AM Re: REDIRECTOUTPUT adds 0 to beginning of file
jbastete Offline
Fresh Scripter

Registered: 2002-06-23
Posts: 17
Loc: Houston
Guys:

I tried to set the redirectoutput to a variable and then set the following code

$Write = ReDirectOutput("\\server\share\$filename")

$Write
", @userid, $os, $fileversion, $ieversion, @address, @DATE"

I still got a 0. I need to import my information into an excel spreedsheet, so getting rid of this 0 would be great.

Any good ideas. [Smile]
_________________________
Net Admin

Top
#1706 - 2002-06-24 01:49 AM Re: REDIRECTOUTPUT adds 0 to beginning of file
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#1707 - 2002-06-24 01:53 AM Re: REDIRECTOUTPUT adds 0 to beginning of file
MCA Offline
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.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.062 seconds in which 0.033 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