dufran3 Posted February 27, 2007 Share Posted February 27, 2007 Below is a function I wrote for pinging a computer. Is there anyway, that instead of writing the results to a logfile/console/msgbox, that I could write them out to a command prompt window? Func _PingCheck($name, $logpath = '') If $logpath == '' Then $logpath = 'C:\pinglog.txt' EndIf $var = Ping($name,250) $FileOpen = FileOpen($logpath,1) If $var Then FileWriteLine($FileOpen,$name & ' status is "up"') FileWriteLine($FileOpen,"Online, roundtrip was: " & $var & ' ms') Else Select Case @error == 1 FileWriteLine($FileOpen,"An error occured with number: " & @error & @CRLF & 'Host is offline') Case @error == 2 FileWriteLine($FileOpen,"An error occured with number: " & @error & @CRLF & 'Host is unreachable') Case @error == 3 FileWriteLine($FileOpen,"An error occured with number: " & @error & @CRLF & 'Bad destination') Case @error == 4 FileWriteLine($FileOpen,"An error occured with number: " & @error & @CRLF & 'Other errors') EndSelect EndIf EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 27, 2007 Moderators Share Posted February 27, 2007 Send() Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
dufran3 Posted February 27, 2007 Author Share Posted February 27, 2007 Really, I thought send was to send keys and text to a window Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 27, 2007 Moderators Share Posted February 27, 2007 Really, I thought send was to send keys and text to a windowhttp://www.autoitscript.com/forum/index.ph...st&p=309892 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
dufran3 Posted February 28, 2007 Author Share Posted February 28, 2007 Hrmm...not sure you are getting at what i'm trying to do. I don't want to send the window a command. Or type anything into the window. I want to output my error messages to a command prompt... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 28, 2007 Moderators Share Posted February 28, 2007 (edited) Hrmm...not sure you are getting at what i'm trying to do. I don't want to send the window a command. Or type anything into the window. I want to output my error messages to a command prompt...To be honest, I'm not sure, if no one else is 100%, maybe google could be your friend. Run(@ComSpec & ' /?') Edited February 28, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
/dev/null Posted February 28, 2007 Share Posted February 28, 2007 Hrmm...not sure you are getting at what i'm trying to do. I don't want to send the window a command. Or type anything into the window. I want to output my error messages to a command prompt... O.K., so what do you think this will do? Send("This is not a command and also I don't type anything into the window. It's just my error message") I'll tell you. It will just write that text into the command window (IF you opened one and it had the focus). However, WHAT are you going to do with that command windows??? I don't get it ..... __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Confuzzled Posted March 4, 2007 Share Posted March 4, 2007 Why not use the version of PING that comes with the OS in a batch file and pipe/append the output to a text file which can then be parsed later?ping www.microsoft.com >> c:\pinglog.txtType PING /? in a command box to see relevant parameters... Link to comment Share on other sites More sharing options...
nfwu Posted March 4, 2007 Share Posted March 4, 2007 The OP wants to display the results in a command prompt like window:@OP: I'd recommend writing the data to a text document then displaying that in notepad.Or, look at http://www.autoitscript.com/forum/index.php?showtopic=19665#) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2007 Share Posted March 4, 2007 Really, I thought send was to send keys and text to a windowit is:_PingCheck("google.com") _PingCheck("cnn.com") Func _PingCheck($name) Run("cmd") WinWait("C:\WINDOWS\system32\cmd.exe") $var = Ping($name, 250) Select Case @error == 1 Send("An error occured with number: " & _ @error & ' Host is offline') Case @error == 2 Send("An error occured with number: " & _ @error & ' Host is unreachable') Case @error == 3 Send("An error occured with number: " & _ @error & ' Bad destination') Case @error == 4 Send("An error occured with number: " & _ @error & ' Other errors') EndSelect If $var Then Send(' status is "up" Online, roundtrip was: ' & $var & ' ms') If $var = 0 Then Send(' Ping failed') EndFunc ;==>_PingCheck [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
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