Page 2 of 2 <12
Topic Options
#182102 - 2007-10-30 05:25 PM Re: multi threading [Re: vroedie]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
You can't remove that part - you need to replace it with your own logic to process each of the elements in your list, such as:

For Each $Element in $SomeArray...

For $Index = 0 to UBound[$SomeArray]
$Element = $SomeArray[$Index]...

While Not @ERROR
$Element = ReadLine(some_source_file_pointer)


The "While $Count..." represented the TOTAL number of processes, while the "If $Workers < 10" limited the number of CONCURRENT processes.

Pick your poison, based on your needs and format of your data.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#182105 - 2007-10-30 06:02 PM Re: multi threading [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Just a shout out to Glenn and Richard for posting these scripts. Good stuff and well documented to help others which is what this board is here for.

Thanks again guys.

Top
#182118 - 2007-10-31 02:06 AM Re: multi threading [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
too much to read but...
in windows, child processed end if parent dies.

but you use run, you create totally new process tree, not child processes under the parents. imo.
_________________________
!

download KiXnet

Top
#182121 - 2007-10-31 02:35 AM Re: multi threading [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Like I said earlier (before war and peace) it's different from the fork/exec in *IX systems, where most children are tied to their parent's process. Much easier to keep things clean there, which is why I make sure the script "children" are self contained and tidy. ;\)

G-
_________________________
Actually I am a Rocket Scientist! \:D

Top
#182136 - 2007-10-31 05:56 PM Re: multi threading [Re: Lonkero]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
first sorry for my english.

Hello lonkero,

i disagree with you about process on windows.
(pre-requisite : pskill.exe and procexp.exe from sysinternals for some tests)

1) a process child doesn't end if parent dies.
Do a very simple test :
from desktop, start the task manager
from the task manager, start a command line (cmd.exe)
at this point, you have the following tree
 Code:
explorer.exe
  taskmanager.exe
    cmd.exe 
Now, in the commandline box, if you execute "pskill explorer", you lost the desktop but task manager and cmd are still alive !!!

2) start a process with RUN in a kix script doesn't start a new process tree.
The process started is a child of kix32 (or wkix32).
Look at the simple code below :
 Code:
run %systemroot%+"\system32\notepad.exe"

? "== script not ended =="
gets $x 

Now start procexp.exe.
You will see that notepad is a child of kix32, which is a child of explorer.
If you end the kix script by pressing any key, notepad is still here but has no parent anymore !!!


3) to come back to jeroen's problem, i suggest to use run "psexec ..." but add -d option to psexec (Don't wait for process to terminate (non-interactive)).
The result depends on the number of hosts to scan.

At my office, i use KiXtart every day for login script, administration and so on... but i have about 4000 workstations to scan and in this case, KiXtart is not enough powerfull
(yes, it is possible to find limit to kix, hard but possible) !!!

So, i have developped with Delphi a program to execute the "unkixable" dirty side of the job. Here is what it is doing :
  • reads hosts from a text file
  • ping a host with a native win32 component (can process 4000 host in about 30 seconds. this is much faster that pings in kix with ping.exe or with WMI )
  • if a host responds, start a new thread that starts a sub-process (exe, vbs, kix, cmd,...) and can wait or not the end of this process. The number of simultaneous threads can be limited to prevent the OS to freeze.

    the sub-process can be started with runas.

    Here is an example on the ini file :
     Code:
    [OPTIONS]
    Ping-TTL=32
    Ping-TimeOut=10
    Ping-DataSize=64
    Ping-NbReply=2
    
    PendingPingsMax=128
    
    batch=false
    Log=true
    Logfile=<your logfile name>
    
    HostFile=<file name of file containing the list of hosts to scan>
    cmdsection=<name of the ini section that describe job to do for each host. See Command section below>
    
    [Command]
    runas=false / true
    username=xxxx
    userdomain=yyyy
    userpassword=zzzz
    
    cmdline=kix32 child.kix $hostname=#hostname# $user=#username# $domain=#userdomain# $pwd=#userpassword#
    currentdirectory=<current directory for the started subprocess>
    
    WaitForTerminate=true
    KillAfterTimeout=false
    Timeout=5000
    
    Hide=true
    Activate=false 

    PendingPingsMax is the maximum number of simultaneous threads.

    KillAfterTimeout is used if WaitForTerminate is true
    Timeout is the delay to kill subprocess when KillAfterTimeout is true

    Hide allows to mask the subprocess window
    Activateallows to activate the subprocess window if it is not hidden

    CommandLine is the exact commandline you want to start BUT #hostname#, #username#, #userdomain# and #userpassword# are replaced at execution by current values.

    if CmdSection or CommandLine are not defined, the tool only pings hosts (just see if hosts are alive).

Usually, this tool allows me to start job on remote hosts from one central point. Each host writes log file on a central shared folder.

If somebody is interested by this tool, i can send it by mail ("only" 803 kb for the .exe).
And sorry if i have been a bit long !!!
_________________________
Christophe

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 611 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.157 seconds in which 0.134 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org