ezzetabi Posted March 5, 2004 Posted March 5, 2004 (edited) Ok, I made this function to know if a computer is on or not. Func _IsTheComputerOn ($computername) Local $ping RunWait(@comspec & " /c ping "& $computername &" -n 1 -w 50>"& @tempdir &"\ping.tmp","",@sw_hide) $ping = FileReadLine(@tempdir &"\ping.tmp",7);<<--- Here my problem ;MsgBox(0,"",$ping) ;------------------------------------De-comment this to see... FileDelete(@tempdir &"\ping.tmp") If StringInStr($ping,"(0%") Then Return 1 EndIf Return 0 EndFunc Strangely enough my script do not read the 7th line but the 4th! I order to take the right line I have to set 13... it is not a big deal, but I'd like to know why... Here an example ping.tmp... (the number at beggining has been added for clarity) 1- 2-Esecuzione di Ping michele.manghi.locale [192.168.0.101] con 32 byte di dati: 3- 4-Risposta da 192.168.0.101: byte=32 durata<10ms TTL=128 5- 6-Statistiche Ping per 192.168.0.101: 7- Pacchetti: Trasmessi = 1, Ricevuti = 1, Persi = 0 (0% persi), 8-Tempo approssimativo percorsi andata/ritorno in millisecondi: 9- Minimo = 0ms, Massimo = 0ms, Medio = 0ms 10- mmm... When I pasted the file from Notepad it added some blank lines making the line I speak of really the 13th... Please,explain me what is going on... Edited March 5, 2004 by ezzetabi
ben_josephs Posted March 5, 2004 Posted March 5, 2004 (edited) Known problem with Microsoft ping. It puts an extra CR at the end of each line. Some applications ignore it; others treat it (wrongly) as an empty line. Notepad seems to be one of those. So does AutoIt! I wonder who wrotre Microsoft ping... Edited March 5, 2004 by ben_josephs
CyberSlug Posted March 5, 2004 Posted March 5, 2004 You could try using the type command to pipe ping.tmp to a properly formatted file. (I've had to do this with exported reg keys.)RunWait(@comspec & " /c type ping.tmp > pingNew.tmp","",@sw_hide) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Guest Cubex Posted March 6, 2004 Posted March 6, 2004 $ping = FileReadLine(@tempdir &"\ping.tmp",13);<<--- Here NO problem
Guest Cubex Posted March 6, 2004 Posted March 6, 2004 Sorry once more all Func _IsTheComputerOn ($computername) Local $ping $pingtmp=@tempdir &"\ping.tmp" RunWait(@comspec & " /c ping "& $computername &" -n 1 -w 50>"& $pingtmp,"",@sw_hide) $ping = FileReadLine($pingtmp,13) ;MsgBox(0,"",$ping) ;------------------------------------De-comment this to see... FileDelete($pingtmp) If StringInStr($ping,"100%") Then Return 0 Else Return 1 EndIf EndFunc
Guest kotschi Posted March 6, 2004 Posted March 6, 2004 @cubex: maybe you could use a better tool for 'pinging'..."ALIVE"http://wettberg.home.texas.net/alive.htmwhich returns different ERRORLEVEL for the net-status:Request timed out : ERRORLEVEL 1Destination host unreachable : ERRORLEVEL 2Destination network unreachable : ERRORLEVEL 3Destination protocol unreachable : ERRORLEVEL 4Destination port unreachable : ERRORLEVEL 5Hardware error : ERRORLEVEL 6TTL expired in transit : ERRORLEVEL 7Bad Destination : ERRORLEVEL 8Other errors : ERRORLEVEL 255I only need this tool for finding out if a pc is online in our network...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now