Jump to content

Recommended Posts

Posted (edited)

I don't see what the problem is, Just use StringReplace, and/or StringLeft combined with StringInStr to extract the hostname, then you're good to go..

Example:

TCPStartup()
 
 Dim $address = "http://www.cast-tv.biz/play/wvx/22540/90FM_3297_IL.wvx"
 
; Remove http:// part
 $hostname = StringReplace($address, "http://", "")
;Extract the hostname from the rest of the address:
 $hostname = StringLeft($hostname, StringInStr($hostname, "/")-1)
 
 MsgBox(0, "Hostname: " & $hostname, "Ip-address: " & TCPNameToIP($hostname))
 
 TCPShutdown()
very good idea!!! thanks!!!

look at this:

ping too..

TCPStartup()

Dim $address = "http://www.cast-tv.biz/play/wvx/22659/383_5457.wvx"

; Remove http:// part
$hostname = StringReplace($address, "http://", "")
;Extract the hostname from the rest of the address:

If StringInStr($hostname, "/" ) Then
$hostname = StringLeft($hostname, StringInStr($hostname, "/")-1)
EndIf

$ip = TCPNameToIP($hostname)

TCPShutdown()


Dim $a=0
$target= "http://www.cast-tv.biz/play/wvx/22659/383_5457.wvx"
if $target="" then
Exit
endif

; Remove http:// part
$target = StringReplace($target, "http://", "")
;Extract the hostname from the rest of the address:

If StringInStr($target, "/" ) Then
$target = StringLeft($target, StringInStr($target, "/")-1)
EndIf

for $g=1 to 5
$pong = Ping ($target,250)
$a=$pong + $a
next

MsgBox(0, "", "Ip Adress: "&$ip&@CRLF&"Ping: "&$a/5)
Edited by Gillboss
Posted (edited)

I would rather use something like this?

Dim $Addreses[4] = ["www.cast-tv.biz", "213.8.138.13", "switch3.castup.net", "radio.coolsite.co.il"]; Define the hostnames/ip's here, in hostname, or ip-address format.

While 1
    For $Address In $Addreses
        _Ping($Address, 500, 4)
        If @error Then
            MsgBox(0, "Error", "Host: " & $Address & " did not respond to ping", 2)
        Else
            ConsoleWrite("Host: " & $Address & " responded fine to ping" & @LF)
        EndIf
    Next
    Sleep(12500); Wait 12.5 seconds before running the loop again
WEnd

Func _Ping($svHost, $ivTimeOut = 1000, $ivTries = 4, $ivSleepTime = 1000)
    Local $avPing[$ivTries+1][2] = [[0]], $ivDivider = 0
    
    For $i = 1 To $ivTries
        $avPing[$i][0] += Ping($svHost, $ivTimeOut)
        $avPing[$i][1] = @error
        $avPing[0][0] += $avPing[$i][0]
        If $avPing[$i][1] Then $avPing[0][1] += 1
        $ivDivider += (Not $avPing[$i][1])
        Sleep($ivSleepTime)
    Next
    Return(SetError($avPing[0][1], Int($avPing[0][0]/$ivDivider), $avPing))
EndFunc

Will continuously ping the hosts defined in the $Addresses array, every 12.5 seconds, and show a message if they don't respond to the pings. muttley

Edited by FreeFry
Posted (edited)

but its not exactly..:

Dim $Addreses[4] = ["www.walla.co.il", "www.google.co.il", "www.nana.co.il", "www.autoitscript.com"]; Define the hostnames/ip's here, in hostname, or ip-address format.

While 1
    For $Address In $Addreses
        _Ping($Address, 500, 4)
        If @error Then
            MsgBox(0, "Error", "Host: " & $Address & " did not respond to ping", 2)
        Else
            ConsoleWrite("Host: " & $Address & " responded fine to ping" & @LF)
        EndIf
    Next
    Sleep(12500); Wait 12.5 seconds before running the loop again
WEnd

Func _Ping($svHost, $ivTimeOut = 1000, $ivTries = 4, $ivSleepTime = 1000)
    Local $avPing[$ivTries+1][2] = [[0]], $ivDivider = 0
   
    For $i = 1 To $ivTries
        $avPing[$i][0] += Ping($svHost, $ivTimeOut)
        $avPing[$i][1] = @error
        $avPing[0][0] += $avPing[$i][0]
        If $avPing[$i][1] Then $avPing[0][1] += 1
        $ivDivider += (Not $avPing[$i][1])
        Sleep($ivSleepTime)
    Next
    Return(SetError($avPing[0][1], Int($avPing[0][0]/$ivDivider), $avPing))
EndFunc
Edited by Gillboss

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...