Page 1 sur 1
[R] Ping + ARP
Posté : mer. 09 sept. 2009 16:26
par africanism
Bonjour a tous
Voila j'ai besoin de votre aide
alors je voudrais faire un truc du genre
un popup qui me demande une ip
ensuite je veut quelle ping cette ip ,apres le ping il face un arp et le resulta ecrit dans un fichier texte .
j'ai commence un script mais je suis perdu
Merci pour votre aide
Code : Tout sélectionner
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
$Ping = InputBox('Adresse Ip', "IP de imp")
$verif = Ping($Ping)
$foo = Run("arp -a " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Msg = GUIGetMsg()
$line = StdoutRead($foo)
SplashTextOn("Line read", $line, -1, -1, -1, -1, 0, "", 20)
Sleep(3000)
SplashOff()
Re: [..] Ping + ARP
Posté : mer. 09 sept. 2009 17:19
par Tlem
Pour récupérer le résultat de la commande ARP (ou toute autre commande DOS), regardez plutôt l'exemple de l'aide de StdoutRead
Re: [..] Ping + ARP
Posté : mer. 09 sept. 2009 17:53
par africanism
merci pour ta reponse mais disons que le suis perdu
Re: [..] Ping + ARP
Posté : mer. 09 sept. 2009 19:21
par timmalos
Peut etre que ceci peut t'aider:
Code : Tout sélectionner
#include <GuiConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
$Debug_IP = False ; Check ClassName being passed to IPAddress functions, set to True and use a handle to another control to see it work
Global $hIPAddress,$msg,$texte = ""
_Main()
Func _Main()
Local $hgui
$hgui = GUICreate("IP Ping et Arg", 400, 500)
$hPing = GUICtrlCreateButton("Ping",205,10,40,25)
$hArg = GUICtrlCreateButton("Arg",260,10,40,25)
$hRes = GUICtrlCreateEdit("",10,40,380,450)
GUICtrlSetFont($hRes, 9, 400, 0, "Courier New")
$hIPAddress = _GUICtrlIpAddress_Create ($hgui, 45, 10,125,25)
GUISetState(@SW_SHOW)
_GUICtrlIpAddress_Set ($hIPAddress, "1.1.192.168")
; Wait for user to close GUI
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $hPing
$foo=Run(@ComSpec & " /k " & 'ping "'&_GUICtrlIpAddress_Get($hIPAddress)&'"', "", @SW_HIDE,$STDOUT_CHILD)
GUICtrlSetData($hRes,"--------------------------------------"&@CRLF & _
"----------Veuillez Patienter----------"&@CRLF & _
"--------------------------------------"&@CRLF & _
"Ping de l'ip "&_GUICtrlIpAddress_Get($hIPAddress)&" en cours"&@CRLF& _
"--------------------------------------"&@CRLF & _
"----------Veuillez Patienter----------"&@CRLF & _
"--------------------------------------"&@CRLF )
While 1
$line = StdoutRead($foo,false,true)
If @error Then ExitLoop
GUICtrlSetData($hRes,GuictrlRead($hRes)&BinaryToString($line,4))
Sleep(500)
Wend
Case $hArg
$foo = Run("arp -a " & _GUICtrlIpAddress_Get($hIPAddress), @SystemDir, @SW_HIDE, $STDOUT_CHILD)
GUICtrlSetData($hRes,"--------------------------------------"&@CRLF & _
"----------Veuillez Patienter----------"&@CRLF & _
"--------------------------------------"&@CRLF & _
"Arp de l'ip "&_GUICtrlIpAddress_Get($hIPAddress)&" en cours"&@CRLF& _
"--------------------------------------"&@CRLF & _
"----------Veuillez Patienter----------"&@CRLF & _
"--------------------------------------"&@CRLF )
While 1
$line = StdoutRead($foo,false,true)
If @error Then ExitLoop
GUICtrlSetData($hRes,GuictrlRead($hRes)&BinaryToString($line,4))
Sleep(50)
Wend
EndSwitch
Sleep(10)
WEnd
EndFunc ;==>_Main
Re: [..] Ping + ARP
Posté : jeu. 10 sept. 2009 11:06
par africanism
merci pour votre aide
voila j'ai reussi a faire ce que je voulais
maintenant je voudrais faire en sorte que quand je clique sur ok dans la fenetre MAC ADRESSE ca me relance la fenetre ip
et si je clique sur la croix ca ferme l'applis.
pouvez vous m'aider ?
Merci a tous
voici mon code
Code : Tout sélectionner
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
$Ping = InputBox('Adresse Ip', "IP de imp")
$verif = Ping($Ping)
$Test = Run("ping " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$foo = Run("arp -a " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Msg = GUIGetMsg()
$line = StdoutRead($foo)
MsgBox(4096, "MAC ADRESSE", $line, 0)
Exit
Re: [..] Ping + ARP
Posté : jeu. 10 sept. 2009 11:21
par kay69
C'est ce que tu cherchais ?
Code : Tout sélectionner
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
While 1
$Ping = InputBox('Adresse Ip', "IP de imp", " ")
If $ping = "" Then Exit
$verif = Ping($Ping)
$Test = Run("ping " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$foo = Run("arp -a " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Msg = GUIGetMsg()
$line = StdoutRead($foo)
$box = MsgBox(4096, "MAC ADRESSE", $line, 0)
WEnd
Re: [..] Ping + ARP
Posté : jeu. 10 sept. 2009 11:46
par africanism
parfait mais peut ton fermer le script en cliquant sur la fenêtre de résulta mac adresse plutôt que ip ?
Re: [..] Ping + ARP
Posté : jeu. 10 sept. 2009 11:53
par kay69
Avec une msgbox comme celle ci dessous oui sinon non.
Code : Tout sélectionner
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
While 1
$Ping = InputBox('Adresse Ip', "IP de imp", " ")
If $ping = "" Then Exit
$verif = Ping($Ping)
$Test = Run("ping " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$foo = Run("arp -a " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Msg = GUIGetMsg()
$line = StdoutRead($foo)
$box = MsgBox(4101, "MAC ADRESSE", $line, 0)
If $box = 2 Then Exit
WEnd
Re: [R] Ping + ARP
Posté : jeu. 10 sept. 2009 13:59
par africanism
Merci parfait.
Re: [R] Ping + ARP
Posté : jeu. 10 sept. 2009 15:35
par africanism
desole encore moi
comment je peut ecrit les info dans un fichier texte ?
voici ce que j'ai fait mais ca ne donne rien
Code : Tout sélectionner
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
While 1
$Ping = InputBox('Adresse Ip', "IP de imp", " ")
If $Ping = "" Then Exit
$verif = Ping($Ping)
$Test = Run("ping " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$foo = Run("arp -a " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Msg = GUIGetMsg()
$line = StdoutRead($foo)
$box = MsgBox(4101, "MAC ADRESSE", $line, 0)
FileWriteLine("d:\mac.txt", "" & GUICtrlRead($line))
If $box = 2 Then Exit
WEnd
Re: [..] Ping + ARP
Posté : jeu. 10 sept. 2009 16:37
par africanism
c'est good j'ai trouve
voici mon code
Code : Tout sélectionner
#include <Constants.au3>
#include <GUIConstants.au3>
#include <File.au3>
#include <Constants.au3>
$file = FileOpen("d:\mac.txt", 1)
While 1
$Ping = InputBox('Adresse Ip', "IP de imp", " ")
If $Ping = "" Then Exit
$verif = Ping($Ping)
$Test = Run("ping " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$foo = Run("arp -a " & $Ping, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
$Msg = GUIGetMsg()
$line = StdoutRead($foo)
$box = MsgBox(4101, "MAC ADRESSE", $line, 0)
_FileWriteToLine("D:\mac.txt", 1, "", 0)
_FileWriteToLine("D:\mac.txt", 2, "" & $line, 0)
FileClose($file)
If $box = 2 Then Exit
WEnd