AutoHotkey Community

It is currently May 27th, 2012, 4:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 98 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject:
PostPosted: March 17th, 2010, 8:36 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
there are 4 key elements. Check below
Code:
hConnect:=FTP_Open(host, 21, id, pw)                 ;underscore
FTP_PutFile(hConnect, fl2snd, target)                 ; underscore
FTP_CloseSocket(hConnect)                             ; missing
FTP_Close()                                  ;undescore


Is there anyone who has had luck with FTP_GetCurrentDirectory ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2010, 2:39 am 
Offline

Joined: April 10th, 2009, 1:46 am
Posts: 139
Location: Wichita,Kansas
thanks for that, but i was refering to the first code, the original post. but with the other code, it doesnt upload. if anyone could help that would be helpfull.

_________________
Drainx1
Your favorite.

What says that we aren't a visualization of someones dream?
And that person could change the laws of physics without thinking a thing about it.
They could recreate the world, and not know what happened.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 5:48 pm 
First, sorry for my bad english... :-(+

I've used the ftp functions. These functions are working fine with Autohotkey. I need for my actual project unicode support and so I've changed to AutohotKey_L. I have with this version a problem. I get the internet handle fine, but with this handle i can't open an ftp connection. I get the error 12007 - The server name could not be resolved.

The server name is ftp.strato.com and i see here no problem with the solving of this server name. Who can help? Is there a unknown problem with Autohotkey_L?

Thanks a lot
M'o


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 5:55 pm 
Here the local variables:

Local Variables for FtpOpen()
--------------------------------------------------
AccessType[1 of 3]: 3
Err_code[5 of 7]: 12007
error_line_number[0 of 0]:
Error_msg[0 of 0]:
OutputVar[0 of 0]:
Password[7 of 7]: xxxxxxx
Port[2 of 3]: 21
Proxy[1 of 3]: 1
ProxyBypass[1 of 3]: 1
Server[14 of 63]: ftp.strato.com
Username[26 of 63]: ftp_xxxx@xxxx.de

And the last code lines:
031: if FtpOpen(ftpServer, ftpPort, ftpUser, ftpPass ,Proxy="", ProxyBypass="")
115: if Username = 0
116: if Password = 0
117: SB_SetText("Baue Verbindung zum Server auf...")
118: if (Proxy != "")
119: AccessType = 3
128: hModule := DllCall("LoadLibrary", "str", "wininet.dll")
130: io_hInternet := DllCall("wininet\InternetOpenA", "str", A_ScriptName, "UInt", AccessType, "str", Proxy, "str", ProxyBypass, "UInt", 0)
137: if (ErrorLevel != 0 || io_hInternet = 0)
142: ic_hInternet := DllCall("wininet\InternetConnectA", "uint", io_hInternet, "str", Server, "uint", Port, "str", Username, "str", Password, "uint" , 1, "uint", 0, "uint", 0) (2.56)
152: Err_code := DllCall("GetLastError")
154: MsgBox,%Err_code% (1.51)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 6:00 pm 
Additional, I get with the ANSI-Version no errors, so I use this version for my project. But I think, this is an error in the Autohotkey_L-UniCode-Version...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 8:59 pm 
Offline
User avatar

Joined: May 10th, 2007, 10:54 am
Posts: 649
Location: .switzerland
hi,

Code:
wininet\InternetConnectA


The A suffix means the ANSI Version of this function, but AHK_L is using Unicode by default.

So you have to use the unicode pendants I sugest. :)



For example:
Quote:
InternetConnectW (Unicode) and InternetConnectA (ANSI)

_________________
http://securityvision.ch
AHK 2D GAME ENGINE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2010, 6:55 am 
@IsNull: Thanks a lot. This solves my problem... :-)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2010, 6:24 pm 
Hi

Using FTP_DeleteFile(hConnect,FileName)

Can I wipe a directory ?

like

FTP_DeleteFile(hConnect,*.*) ??

Thanks :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2010, 4:28 pm 
Can anyone advise how to add a progress bar to the FTP download ??

Could it be done with this :
http://www.autohotkey.com/forum/topic11 ... p+progress

How ?

Thanks :)


Report this post
Top
  
Reply with quote  
 Post subject: FTP file write
PostPosted: July 5th, 2010, 11:08 am 
Offline

Joined: July 2nd, 2010, 5:36 pm
Posts: 17
Can anyone tell me how I can ad some text to a txt file on a host without downloading it and then uploading it again?

I've searched the forum but haven't found a FTP write function


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2010, 11:24 am 
Quote:
Can anyone tell me how I can ad some text to a txt file on a host without downloading it and then uploading it again?
You can´t.
It´s not implemented in FTP .


Report this post
Top
  
Reply with quote  
 Post subject: Re: FTP file write
PostPosted: July 5th, 2010, 11:43 am 
Offline

Joined: March 21st, 2007, 7:50 pm
Posts: 76
webster14 wrote:
Can anyone tell me how I can ad some text to a txt file on a host without downloading it and then uploading it again?

I've searched the forum but haven't found a FTP write function



you can do with ftp.exe


Code:
open "url"
user  "user" "passw"
append "local txt file" "ftp server txt file"




Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2010, 2:57 pm 
Offline
User avatar

Joined: October 18th, 2008, 2:09 pm
Posts: 429
drainx1 wrote:
thanks for that, but i was refering to the first code, the original post. but with the other code, it doesnt upload. if anyone could help that would be helpfull.


I got this to work, I needed something to upload a single file only, wanted it into a single exe so the user doesn't need to know the password:

Code:
server = ftp.autohotkey.com
port = 21
user = username_here
password = password_here
remotedir = remotedir_here
local = local_filename_here
remotefile = %local%

ifnotexist %local%
{
   Msgbox , The file "%local%" is missing in "%A_ScriptDir%".`n`nPlease copy the file to "%A_ScriptDir%" and restart this program.`n`nThis program will now close.
   exitapp
}

FtpOpen(server,port,user,password)
FtpSetCurrentDirectory(remotedir)
FtpPutFile(local,remotefile)
FtpClose()

exitapp

FtpOpen(Server, Port=21, Username=0, Password=0 ,Proxy="", ProxyBypass="") {
IfEqual, Username, 0, SetEnv, Username, anonymous
IfEqual, Password, 0, SetEnv, Password, anonymous

If (Proxy != "")
AccessType=3
Else
AccessType=1
;#define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
;#define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
;#define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
;#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS

global ic_hInternet, io_hInternet, hModule
hModule := DllCall("LoadLibrary", "str", "wininet.dll")

io_hInternet := DllCall("wininet\InternetOpenA"
, "str", A_ScriptName ;lpszAgent
, "UInt", AccessType
, "str", Proxy
, "str", ProxyBypass
, "UInt", 0) ;dwFlags

If (ErrorLevel != 0 or io_hInternet = 0) {
FtpClose()
return 0
}

ic_hInternet := DllCall("wininet\InternetConnectA"
, "uint", io_hInternet
, "str", Server
, "uint", Port
, "str", Username
, "str", Password
, "uint" , 1 ;dwService (INTERNET_SERVICE_FTP = 1)
, "uint", 0 ;dwFlags
, "uint", 0) ;dwContext

If (ErrorLevel != 0 or ic_hInternet = 0)
return 0
else
return 1
}

FtpClose() {
global ic_hInternet, io_hInternet, hModule
DllCall("wininet\InternetCloseHandle",  "UInt", ic_hInternet)
DllCall("wininet\InternetCloseHandle",  "UInt", io_hInternet)
DllCall("FreeLibrary", "UInt", hModule)
}

FtpSetCurrentDirectory(DirName) {
global ic_hInternet
r := DllCall("wininet\FtpSetCurrentDirectoryA", "uint", ic_hInternet, "str", DirName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}

FtpPutFile(LocalFile, NewRemoteFile="", Flags=0) {
;Flags:
;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY)
;FTP_TRANSFER_TYPE_ASCII = 1
;FTP_TRANSFER_TYPE_BINARY = 2
If NewRemoteFile=
NewRemoteFile := LocalFile
global ic_hInternet
r := DllCall("wininet\FtpPutFileA"
, "uint", ic_hInternet
, "str", LocalFile
, "str", NewRemoteFile
, "uint", Flags
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2010, 4:29 pm 
Offline

Joined: April 10th, 2009, 1:46 am
Posts: 139
Location: Wichita,Kansas
Awesome. thats works perfectly!
Thanks!

_________________
Drainx1
Your favorite.

What says that we aren't a visualization of someones dream?
And that person could change the laws of physics without thinking a thing about it.
They could recreate the world, and not know what happened.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2010, 6:28 pm 
Offline
User avatar

Joined: October 18th, 2008, 2:09 pm
Posts: 429
drainx1 wrote:
Awesome. thats works perfectly!
Thanks!


you're welcome. You could achieve the same with FileAppend and FTP:
http://www.autohotkey.com/docs/commands/FileAppend.htm
Code:
; The following example demonstrates how to automate FTP uploading using the operating
; system's built-in FTP command. This script has been tested on Windows XP and 98se.

FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile%  ; In case previous run was terminated prematurely.

FileAppend,  ; The comma is required in this case.
(
open host.domain.com
username
password
binary
cd htdocs
put %VarContainingNameOfTargetFile%
delete SomeOtherFile.htm
rename OldFileName.htm NewFileName.htm
ls -l
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile%  ; Delete for security reasons.
Run %FTPLogFile%  ; Display the log for review.

But I don't like that the password is in a file that was written to the drive and can be "undeleted".


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 98 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group