Sign in to follow this  
Followers 0
ChrisL

Can you do several things at once?

3 posts in this topic

#1 ·  Posted (edited)

Not sure if this is going to come out written quite like what I am thinking..

What I want to do is to search for a computer (as previous thread)

The computer may be of various name and workgroup, so what I am doing is finding the IP address of the machine I'm running the script from which could be 2 different ones as there are 2 network cards in the machine, so I leave the first 3 octets of the IP as is then count through 1 to 255 pinging the address for a responce, if there is a responce I then check for a file that would exist on the desired machine.

Now I need to do this for each network card, so can I lob it in a function and run 2 functions simultaneously? If so how? It takes a while to run through the list of IP's so I figured I could halve the time it would be better.

Any thoughts?

Cheers

Chris

Code so far...

#include <array.au3>
#include <file.au3>

$Computername = @computername
$MyIP1 = @IPAddress1
$MyIP2 = @IPAddress2
$MyIP3 = @IPAddress3
$MyIP4 = @IPAddress4

Dim $aFrontiers = _ArrayCreate ("Frontier", "Frontier1", "EZPC00")

$aOctets = StringSplit($MyIp1, ".")
 
_FileCreate ( "Ping.txt" )


$IpCount = 0


while $IPCount < 255

$PingResult = Ping($aOctets[1] & "." & $aOctets[2] & "." & $aOctets[3] & "." & $IPCount )
$Path = $aOctets[1] & "." & $aOctets[2] & "." & $aOctets[3] & "." & $IPCount

;Check Ping for reply and see if frontier
If $PingResult = 0 then;do nothing continue pinging
    
    Else;check if its a frontier
        $IsFrontier = FileExists ( "\\" & $Path & "\D$\Fujifilm\Frontier" )
        if $IsFrontier = 0 then;if not a frontier do nothing and continue
        
        Else
;Now know its a frontier.. what to do with it now?
        _ArrayAdd ( $aFrontiers, $Path )

        MsgBox (0,"",$IsFrontier)
    Endif
Endif


;Logging
$file = FileOpen("Ping.txt", 1)
FileWriteLine ($file, $aOctets[1] & "." & $aOctets[2] & "." & $aOctets[3] & "." & $IPCount & " : " & $PingResult)
$IPCount = $IPCount + 1
FileClose($file)
Wend



_ArrayDisplay ($aFrontiers,"")
Edited by ChrisL

Share this post


Link to post
Share on other sites



Thinking about it.. would I be quicker to just check for the file/folder rather than pinging?

not sure, but you can test by timing a non-responding ping and a file check, using timerinit() and timerdiff(), then compare the results.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0