Greek Posted September 20, 2013 Share Posted September 20, 2013 (edited) Hi, expandcollapse popup$user = _URIEncode("tester@bla.com"); // Only example $password = _URIEncode("my:password"); ; Advanced example - downloading in the background Local $hDownload = InetGet("ftp://"&$user&":"&$password&"@ftp.strato.de/IMG_0001.JPG", @ScriptDir&"\test.jpg", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ; Close the handle to release resources. MsgBox(0, "", "Bytes read: " & $nBytes) Func _URIEncode($sData) ; Prog@ndy Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"") Local $nChar $sData="" For $i = 1 To $aData[0] ;~ ConsoleWrite($aData[$i] & @CRLF) $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48-57, 65 To 90, 95, 97 To 122, 126 $sData &= $aData[$i] Case 32 $sData &= "+" Case Else $sData &= "%" & Hex($nChar,2) EndSwitch Next Return $sData EndFunc Func _URIDecode($sData) ; Prog@ndy Local $aData = StringSplit(StringReplace($sData,"+"," ",0,1),"%") $sData = "" For $i = 2 To $aData[0] $aData[1] &= Chr(Dec(StringLeft($aData[$i],2))) & StringTrimLeft($aData[$i],2) Next Return BinaryToString(StringToBinary($aData[1],1),4) EndFunc Shouldn't InetGet be able to download it? Seems like : and/or @ breaks it even when I escape it. If I ClipPut the URL it works flawless in IE/Chrome Greetings Greek Edit: My bad, I edited the question Edited September 20, 2013 by Greek Link to comment Share on other sites More sharing options...
BrewManNH Posted September 20, 2013 Share Posted September 20, 2013 And your problem/question is? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 20, 2013 Moderators Share Posted September 20, 2013 Greek,And the problem is? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Greek Posted September 20, 2013 Author Share Posted September 20, 2013 And your problem/question is? Shouldn't this work if I escape : and @ ? It works with IE Link to comment Share on other sites More sharing options...
Greek Posted September 20, 2013 Author Share Posted September 20, 2013 Should I make a ticket for this? I can pm FTP test data to a Moderator/Developer/MVP if someone wants to try it. If Internet Explorer can download it then InetGet should be able to download it too or not? Link to comment Share on other sites More sharing options...
AutID Posted September 20, 2013 Share Posted September 20, 2013 The guy who will understand where the problem is please send it to me via pm. I am very curious to see what it is! https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Greek Posted September 20, 2013 Author Share Posted September 20, 2013 (edited) Thought it would be clear now: The problem is that you can't use special chars like : or @ as user name or password. As you can see here: $user = _URIEncode("tester@bla.com"); // Only example $password = _URIEncode("my:password"); ; Advanced example - downloading in the background Local $hDownload = InetGet("ftp://"&$user&":"&$password&"@ftp.strato.de/IMG_0001.JPG", @ScriptDir&"\test.jpg", 1, 1) Edit: I don't know why my whole post doesn't show up, this editor trims always... Edit2: Hope he keeps it now: The URL in InetGet is a valid URL for IE, you get the image. With InetGet I don't get it. Edited September 21, 2013 by Greek Link to comment Share on other sites More sharing options...
jguinch Posted September 21, 2013 Share Posted September 21, 2013 Can you look at this link ? Your problem may be related Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
AutID Posted September 21, 2013 Share Posted September 21, 2013 (edited) Well I don't know if it is inetget problem because when I navigate the url, the ftp server requires an account which I don't have so I cant take a deeper look. Anyway in case it is inetget function try this expandcollapse popup$user = _URIEncode("tester@bla.com") $password = _URIEncode("my:password") Global $path = @ScriptDir & "\test.jpg" Local $hDownload = "ftp://"&$user&":"&$password&"@ftp.strato.de/IMG_0001.JPG" ConsoleWrite($hDownload& @LF) FileDownload($hDownload, $path) Func FileDownload($url, $SavePath) Local $xml, $Stream $xml = ObjCreate("Microsoft.XMLHTTP") $Stream = ObjCreate("Adodb.Stream") $xml.Open("GET", $url, 0) $xml.Send $Stream.Type = 1 $Stream.Open $Stream.write($xml.ResponseBody) $Stream.SaveToFile($SavePath) $Stream.Close EndFunc Func _URIEncode($sData) Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"") Local $nChar $sData="" For $i = 1 To $aData[0] ;~ ConsoleWrite($aData[$i] & @CRLF) $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48-57, 65 To 90, 95, 97 To 122, 126 $sData &= $aData[$i] Case 32 $sData &= "+" Case Else $sData &= "%" & Hex($nChar,2) EndSwitch Next Return $sData EndFunc Func _URIDecode($sData) Local $aData = StringSplit(StringReplace($sData,"+"," ",0,1),"%") $sData = "" For $i = 2 To $aData[0] $aData[1] &= Chr(Dec(StringLeft($aData[$i],2))) & StringTrimLeft($aData[$i],2) Next Return BinaryToString(StringToBinary($aData[1],1),4) EndFunc Edited September 21, 2013 by AutID https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Greek Posted September 21, 2013 Author Share Posted September 21, 2013 (edited) "Well I don't know if it is inetget problem because when I navigate the url, the ftp server requires an account which I don't have so" It works with with url and the right data. So I think there must be a problem with InetGet. mh I get this: test.au3 (16) : ==> The requested action with this object has failed.: $xml.Send $xml.Send^ ERROR Edited September 22, 2013 by Greek Link to comment Share on other sites More sharing options...
AutID Posted September 21, 2013 Share Posted September 21, 2013 "Well I don't know if it is inetget problem because when I navigate the url, the ftp server requires an account which I don't have so" It works with with url and the right data. So I think there but be a problem with InetGet. mh I get this: test.au3 (16) : ==> The requested action with this object has failed.: $xml.Send $xml.Send^ ERROR Neither INetGet or Filedownload functions have problem. The problem is in the encode decode function, or somewhere else in you script. $xml.Send fails because your data is wrong. You provide the user like this: tester%40bla.com And the password like this: my%3Apassword which means the "@" gets replaced by "%40" and the ":" gets replaced by "%3A". So something you are doing wrong. Either provide your entire script either your credentials for test(which I don't recommend) either get over it. https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Greek Posted September 22, 2013 Author Share Posted September 22, 2013 pm'ed you test data Link to comment Share on other sites More sharing options...
AutID Posted September 22, 2013 Share Posted September 22, 2013 (edited) The problem is in your password. Downloading something with INetGet you have to provide username:password like this :http://myuser:mypassword@www.somesite.comYour password is like this "password:password" so this sigh ":" within your password is getting INetGet function confused. I don't know if it is a bug cuz it is not an udf so I cant take a look on it.Try changing temporary your password without that sigh within it and try inetget function again.Edit: When I navigate it manually the site navigates normally, using inetget doesn't seem to work even if I give the entire url with the credentials. The error though is your password. Or at least that's what error check says.Try changing your password and try again. Edited September 22, 2013 by AutID https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Greek Posted September 22, 2013 Author Share Posted September 22, 2013 This topic is all about special chars in the user name / password, I made this password an purpose, that's what I wanted to test. I wonder why InetGet can't handle this when IE can handle it if it's escaped. Link to comment Share on other sites More sharing options...
AutID Posted September 23, 2013 Share Posted September 23, 2013 I posted you an answer with a debugger of the script explaining the extended of the inetget error since it contains credentials. Try encoding your password with other chars besides those. Change it and encode other letters besides those on @ProgAndy's function. It is easy if you read a bit the help files for the ASCII codes. https://iblockify.wordpress.com/ 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