sekyao Posted December 17, 2004 Share Posted December 17, 2004 Dear all,i am currently creating an program to ping a certain URL and (if successful), send a GET id to the ping-ed url . part of the coding is as follow :...$str_url = "URL?B=" & $str_code If RunWait("ping.exe -n 1 " & "URL", "", @SW_HIDE) == 0 Then ; Connection is established. $str_result = URLDownloadToFile($str_url, $tmpFile) ....However, i have tested on several pc at different location and pc's setting. The problem i'm facing at the moment is that at some pc, the script work fine, while other would face problem, and thirdly ( at most confusing) it is pingable but the URLDownloadToFile does not transfer the $str_code to the URL. So i was wandering if there is any alternative to URLDownloadToFile or advice on this matter? Link to comment Share on other sites More sharing options...
themax90 Posted December 17, 2004 Share Posted December 17, 2004 (edited) It must be an COMPLETE URL. Like http://www.autoitscript.com/index.html. URLDownlodToFile will not download Php documents or interlaced MySql stuff.There is an alternative but it's in the Version 3.0.103 Beta which is unstable.You can download the beta at http://www.autoitscript.com/autoit3/files/unstable/autoit/or for the excutablehttp://www.autoitscript.com/autoit3/files/...it-v3.0.103.exeI'm not sure if Absolute Url's work, but you can always find out.InetGet --------------------------------------------------------------------------------Downloads a file from the internet using the http or ftp protocol.InetGet ( "URL", "filename" [, reload [, background]] )ParametersURL URL of the file to download. See remarks below. filename Local filename to download to. reload [optional]0 = (default) Get the file from local cache if available1 = Forces a reload from the remote site background [optional]0 = (default) Wait until the download is complete before continuing.1 = return immediately and download in the background (see remarks). Return ValueSuccess: Returns 1. Failure: Returns 0. RemarksInternet Explorer 3 or greater must be installed for this function to work.The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.To use a username and password when connecting simply prefix the servername with "username:password@", e.g."http://myuser:mypassword@www.somesite.com"The InetGet function works with http:// https:// and ftp:// - to change the transfer type when using ftp see the FtpBinaryMode option."background" ParameterBy default the function waits until the download has finished before returning. Sometimes with large downloads this is not always wanted. If the background parameter is set to 1 the function returns immediately and the download continues in the background. When in this mode two macros are used to keep track:@InetGetActive = 1 while downloading, or 0 when finished.@InetGetBytesRead = the number of bytes downloaded, or -1 if there has been an error.Note, only one download can be active at once, if you call the function again before a download is complete it will fail.RelatedFtpBinaryMode (Option), FtpSetProxy, InetGetSize, HttpSetProxy, ExampleInetGet("http://www.mozilla.org", "C:\foo.html")InetGet("http://www.autoitscript.com", "C:\mydownload.htm", 1)InetGet("ftp://ftp.mozilla.org/pub/mozilla.org/README", "README.txt", 1); Advanced example - downloading in the backgroundInetGet("http://www.nowhere.com/somelargefile.exe", "test.exe", 1, 1)While @InetGetActive TrayTip("Downloading", "Bytes = " & @InetGetBytesRead, 10, 16) Sleep(250)WendMsgBox(0, "Bytes read", @InetGetBytesRead) Edited December 17, 2004 by Agent Smith Link to comment Share on other sites More sharing options...
sekyao Posted December 17, 2004 Author Share Posted December 17, 2004 Thank you for the information. but i'm dont actually wanna download the file down. just wanna use autoIT to push a variable ( $str_code ) to URL if the ping result return sucess Link to comment Share on other sites More sharing options...
themax90 Posted December 17, 2004 Share Posted December 17, 2004 (edited) Then it must be a domain to Ping it, you cannot ping a file. Make sure it's a domain like www.google.com or www.mozilla.org. It can also be an Ip address. You can to a domain query to find the main servers ip address of the domain and ping that. Edited December 17, 2004 by Agent Smith Link to comment Share on other sites More sharing options...
sekyao Posted December 17, 2004 Author Share Posted December 17, 2004 the domain to ping is correct. Have tried of manual ping as well as autoit ping and result obtained from ping == 0. also, i have written the ping statement as a if-else , so on else case, a log file would be created but so far no log file. so i doubt that the ping has failed. Link to comment Share on other sites More sharing options...
themax90 Posted December 17, 2004 Share Posted December 17, 2004 (edited) $str_url = "URL?B=" & $str_code $str_url = "URL?B=" & $str_code Whats that stuff?And you can't have a function in the If bar. Can you send me the source, I will debug it for you...If RunWait("ping.exe -n 1 " & "URL", "", @SW_HIDE) == 0 Then; Connection is established.$str_result = URLDownloadToFile($str_url, $tmpFile) Should be$run = RunWait("ping.exe -n 1 " & "URL", "", @SW_HIDE)If $run == 0 Then; Connection is established.$str_result = URLDownloadToFile($str_url, $tmpFile) See you can't run a function if it is in the if statement. But it runs it right before the If statement and logs it in a variable. So it actually has something to do... Hehe Edited December 17, 2004 by Agent Smith Link to comment Share on other sites More sharing options...
sekyao Posted December 17, 2004 Author Share Posted December 17, 2004 b is a capture variable that is detected by URL to received the $str_code. also, are you sure about RUNWAIT in a IF-ELSE statement?. some pc work fine with this setting. but,nontheless, i'll modify my coding and see if the problem is resolved or not. Link to comment Share on other sites More sharing options...
themax90 Posted December 17, 2004 Share Posted December 17, 2004 (edited) You can't have that capture there. It must be a literal string.http://www.nowhere.com/somefile.exe is a good example.you can't have http://www.nowhere.com/somefile.exe?b= & str_codeIt must be the actual file other wise it will not work. Please give me a copy of the source and I will debug it for you. Edited December 17, 2004 by Agent Smith Link to comment Share on other sites More sharing options...
sekyao Posted December 17, 2004 Author Share Posted December 17, 2004 $str_url = "URL?B=" & $str_branch Do If RunWait("ping.exe -n 1 " & "URL", "", @SW_HIDE) == 0 Then $int_count = 0 ; Connection is established. $str_result = URLDownloadToFile($str_url, $tmpFile) Else ;Internet is down $int_count = $int_count + 1 $str_resultfile2= _FileWriteLog($str_file, "Connection Lost") If Mod ($int_count, 5 ) == 0 Then MsgBox(0, "Internet Connection", "Internet connection is down", 30) EndIf EndIf Sleep(300000) Until $i = 0note : actual URL is replaced with the term URLsorry. but i cannot be more even specific nor provide additional information on the coding then those provided above. Link to comment Share on other sites More sharing options...
themax90 Posted December 17, 2004 Share Posted December 17, 2004 Please give me the ACTUAL url Link to comment Share on other sites More sharing options...
themax90 Posted December 17, 2004 Share Posted December 17, 2004 (edited) I am working on a duplicate WORKING script, I don't think u actually understand autoit completely You must supply me with the full script otherwise none of us will be able to figure this out, don't worry we wont steal you stuff.. Edited December 17, 2004 by Agent Smith Link to comment Share on other sites More sharing options...
sekyao Posted December 17, 2004 Author Share Posted December 17, 2004 nevermind , have found the solution. thanks to all for the help Link to comment Share on other sites More sharing options...
sugi Posted December 17, 2004 Share Posted December 17, 2004 And you can't have a function in the If bar. [...]If RunWait("ping.exe -n 1 " & "URL", "", @SW_HIDE) == 0 Then[...]The AutoIt part of this line is valid. You can have a function in an expression. 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