Page 1 of 1 1
Topic Options
#37274 - 2003-03-04 03:06 PM ADS memberlist output to textfile
Anonymous
Unregistered


Hi

I browsed and searched this forum a bit and found some nice ideas for scripts i have to use.

I have to get a userlist in textfile from our ADS and when i use this script all seems fine:

$LogFile = test.txt
$DomObj = getobject("WinNT://xxx.xxx.com,domain")
$DomObj.filter = "user",""
for each $user in $DomObj
? $user.name
next


when i add the REDIRECTOUTPUT command the output is only ZK18187, the last user in alphabetical order:


$LogFile = test.txt
$DomObj = getobject("WinNT://xxx.xxx.com,domain")
$DomObj.filter = "user",""
for each $user in $DomObj
;? $user.name

IF REDIRECTOUTPUT($LogFile,1) = 0
? $user.name
ENDIF

next


What am i doing wrong ? We have Win200 ADS with about 9000 users.

Help appreciated for a scripnewbie.

thanks.

Top
#37275 - 2003-03-04 03:08 PM Re: ADS memberlist output to textfile
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yap ,
thats simple !

You specified the Redirectoutput within your loop

Just place the function call outside any loop and Bob's your uncle

hth
_________________________



Top
#37276 - 2003-03-04 03:11 PM Re: ADS memberlist output to textfile
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
like here :



$LogFile = @scriptdir + "\test.txt" ;add a valid path !
$ = redirectoutput($LogFile,1)

$DomObj = getobject("WinNT://xxx.xxx.com,domain")
$DomObj.filter = "user",""

for each $user in $DomObj 
    ? $user.name 
next



[ 04. March 2003, 15:12: Message edited by: jpols ]
_________________________



Top
#37277 - 2003-03-04 03:11 PM Re: ADS memberlist output to textfile
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
REDIRECTOUTPUT is a 'toggle', thus should not be within a loop. Alternatively, use OPEN/WRITELINE/CLOSE. See also the FAQ Forum under File Input/Output Primer . And please post scripts code in between CODE tags as specified in the FAQ Forum.
code:
$LogFile = test.txt
$DomObj = getobject("WinNT://xxx.xxx.com,domain")
$DomObj.filter = "user",""
$rc=REDIRECTOUTPUT($LogFile,1)
for each $user in $DomObj
? $user.name
next
$rc=REDIRECTOUTPUT('')



[ 04. March 2003, 15:12: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#37278 - 2003-03-04 03:13 PM Re: ADS memberlist output to textfile
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Could you also just leave it in the loop, but set the "overwrite" parameter to 0?
_________________________
Eric

Top
#37279 - 2003-03-04 03:17 PM Re: ADS memberlist output to textfile
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
No,

that would then toggle between redirect and print to console ...
_________________________



Top
#37280 - 2003-03-04 03:17 PM Re: ADS memberlist output to textfile
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why would you want to do that? It's sufficient to redirect the output once.
_________________________
There are two types of vessels, submarines and targets.

Top
#37281 - 2003-03-04 03:18 PM Re: ADS memberlist output to textfile
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Just to be somewhat of a contrarian here, I don't like Redirectoutput and prefer using Writelog2() UDF for output. I have no good reason for my dislike of Redirectoutput, just offering a different flavor of ice cream.

[ 04. March 2003, 15:18: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#37282 - 2003-03-04 03:20 PM Re: ADS memberlist output to textfile
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
In that case, I would have to offer DisplayText() - Display text incl. logging option which displays oputput both on the screen and writes it into an optional log file. Additionally, the screen output can be rerouted into another logfile, thus creating multi-level logging.
_________________________
There are two types of vessels, submarines and targets.

Top
#37283 - 2003-03-04 03:24 PM Re: ADS memberlist output to textfile
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I'd additionally suggest a web-based database solution to store the Information in ...
(I think Table color in Flieder saves the most RAM [Razz] )

ROFL !!!

[ 04. March 2003, 15:25: Message edited by: jpols ]
_________________________



Top
#37284 - 2003-03-04 03:24 PM Re: ADS memberlist output to textfile
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I never use redirectoutput. I didn't realize it was a toggle until after I posted my reply. Thanks for clearing things up for me.
_________________________
Eric

Top
#37285 - 2003-03-04 03:27 PM Re: ADS memberlist output to textfile
Anonymous
Unregistered


sealeopard, jpols many thanks for your comments.

You were right about the loop and its working great now, have to say i just started this (again) a bit, getting loads of good stuff from this forum tho.

Thanks again for the fast replies.

[Smile]

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
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.049 seconds in which 0.019 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