Sign in to follow this  
Followers 0
zichy

Help with _FTPCommand (ftp.au3)

10 posts in this topic

#1 ·  Posted (edited)

Hi am unable to get the _FTPCommand() function kindly added to the very usefull ftp.au3 to work

Heres an example

;;;;;;; Start here;;;;;;;;;

#include <FTP.au3>

$server = '10.0.0.5'

$username = 'user1'

$pass = 'password'

$ftpsession = 'MyFtp'

$Open = _FTPOpen($ftpsession)

$Conn = _FTPConnect($Open, $server, $username, $pass)

$myFtpDir = _FTPCommand($Conn, "ls /myfolder c:\1.txt"); , 0x00000001)

$Ftpc = _FTPClose($Open)

;;;;;End here

Tried it on windows and VMS ftp servers same result, no output file, also tried dir instead of ls. This command works fine in a cmd prompt with windows built in ftp.exe

Or is there another way somewhone knows of to run this (or other ftp) commands within AuotIT using ftp.au3's functions?

Also :o,

related to ftp.au3,

I just love the _FTPPutFolderContents function (thanks to coder)

Anyone have or able to create a

_FTPGetFolderContents function?

Regards and many thanks to ftp.au3 coders and add-on function writers, and all the other helpfull people whom frequent this site.

Edited by zichy

Share this post


Link to post
Share on other sites



Hi am unable to get the _FTPCommand() function kindly added to the very usefull ftp.au3 to work

Heres an example

;;;;;;; Start here;;;;;;;;;

#include <FTP.au3>

$server = '10.0.0.5'

$username = 'user1'

$pass = 'password'

$ftpsession = 'MyFtp'

$Open = _FTPOpen($ftpsession)

$Conn = _FTPConnect($Open, $server, $username, $pass)

$myFtpDir = _FTPCommand($Conn, "ls /myfolder c:\1.txt"); , 0x00000001)

$Ftpc = _FTPClose($Open)

;;;;;End here

Tried it on windows and VMS ftp servers same result, no output file, also tried dir instead of ls. This command works fine in a cmd prompt with windows built in ftp.exe

Or is there another way somewhone knows of to run this (or other ftp) commands within AuotIT using ftp.au3's functions?

Also :o,

related to ftp.au3,

I just love the _FTPPutFolderContents function (thanks to coder)

Anyone have or able to create a

_FTPGetFolderContents function?

Regards and many thanks to ftp.au3 coders and add-on function writers, and all the other helpfull people whom frequent this site.

If you are referring to the FTP command function I added to the FTP.au3 library, that will only execute a command (like CDUP or PASV) and return success or an error. I believe the problem lies in the inability of the dllcall function to handle a callback (someone please correct me if I'm wrong), so I am not sure about returning a response from a ls or dir command.

I'll have to play with it when I have some time. I'll let you know what I find.

Share this post


Link to post
Share on other sites

If you are referring to the FTP command function I added to the FTP.au3 library, that will only execute a command (like CDUP or PASV) and return success or an error. I believe the problem lies in the inability of the dllcall function to handle a callback (someone please correct me if I'm wrong), so I am not sure about returning a response from a ls or dir command.

I'll have to play with it when I have some time. I'll let you know what I find.

Appreciate response and thanks for taking a look when you have some time

:o

Nobody have a _FTPGetFolderContents function? or has anyone worked out a way to get a ftp directory list with ftp.au3 or AutoIt generally?

Thanks again billmez

Share this post


Link to post
Share on other sites

Appreciate response and thanks for taking a look when you have some time

:o

Nobody have a _FTPGetFolderContents function? or has anyone worked out a way to get a ftp directory list with ftp.au3 or AutoIt generally?

Thanks again billmez

I've installed the latest release of AutoIT but I don't have the ftp files referenced. It there an additional download I need to get. I've searched for FTP.au3 but that's not on my system. Where do I get it?

Share this post


Link to post
Share on other sites

I've installed the latest release of AutoIT but I don't have the ftp files referenced. It there an additional download I need to get. I've searched for FTP.au3 but that's not on my system. Where do I get it?

Bumping my own post! I found FTP.au3 following a search via Google which was a link back to this forum! Guess I should have searched here first! :o

Anyway, I downloaded the code and added it to my #include directory and I'm sending a 100Mb zip file to our US server and it seems to be working ok. Some questions come to mind:

1. I usually use a DOS command prompt and run ftp that way. Once connected I'm used to using the BINARY command which, the gurus at work tell me I have to use. FTP.au3 does not provide a specific "mode setting" function so can I assume that it is sending in BINARY mode implictly. I'll only know in about an 30 minutes when the file has been sent and I can unzip it.

2. I can monitor the state of the transfer in a command prompt with the ls -l command I can see the file is getting sent but I have no idea when it's actually finished. Is there some way of finding out? I'd rather stay in the script and monitor it and possibly display some progress information. Is it possible to do that and has anyone got some sample code for me?

Share this post


Link to post
Share on other sites

I used the FTP.au3 in one of my original scripts, but found this to be easier:

http://www.pacific.net/~ken/software/

The program is called wcl_ftp...the the wcl = windows command line. So it's very easy to integrate into a script using the Run command. It gives you the option of seeing a window that displays the progress and results and you HAVE to specify what mode to transfer in, which is both good and bad. It can also log all the screen info too. The website looks like crap but the application is pretty nice...otherwise I have no other suggestions...good luck!

Share this post


Link to post
Share on other sites

The website looks like crap but the application is pretty nice...otherwise I have no other suggestions...good luck!

You're right there. That is one mother of a crap website. Looks like the Incredible Hulk has crapped on it. :o

Share this post


Link to post
Share on other sites

I used the FTP.au3 in one of my original scripts, but found this to be easier:

http://www.pacific.net/~ken/software/

The program is called wcl_ftp...the the wcl = windows command line. So it's very easy to integrate into a script using the Run command. It gives you the option of seeing a window that displays the progress and results and you HAVE to specify what mode to transfer in, which is both good and bad. It can also log all the screen info too. The website looks like crap but the application is pretty nice...otherwise I have no other suggestions...good luck!

Will give this a look, thanks people, anyone else got any ideas?

Share this post


Link to post
Share on other sites

Bumping my own post! I found FTP.au3 following a search via Google which was a link back to this forum! Guess I should have searched here first! :)

Anyway, I downloaded the code and added it to my #include directory and I'm sending a 100Mb zip file to our US server and it seems to be working ok. Some questions come to mind:

1. I usually use a DOS command prompt and run ftp that way. Once connected I'm used to using the BINARY command which, the gurus at work tell me I have to use. FTP.au3 does not provide a specific "mode setting" function so can I assume that it is sending in BINARY mode implictly. I'll only know in about an 30 minutes when the file has been sent and I can unzip it.

2. I can monitor the state of the transfer in a command prompt with the ls -l command I can see the file is getting sent but I have no idea when it's actually finished. Is there some way of finding out? I'd rather stay in the script and monitor it and possibly display some progress information. Is it possible to do that and has anyone got some sample code for me?

Here are some constants that can be used in the _FTPPutFile() function for the $l_Flags parameter

Const $INTERNET_FLAG_TRANSFER_ASCII = 0x00000001
Const $INTERNET_FLAG_TRANSFER_BINARY = 0x00000002

Someplace in the original thread you should find an additionl function for ftp command which can send "Type A" and "Type I" and "PASV" commands to the server before the transfer.

This should work well for you. I have found it much easier than using command line tools like MS ftp (which won't use passive transfers). If you have to use command line search for a program called move it freely, which is a free MS ftp substitute that supports passive mode transfers.

Share this post


Link to post
Share on other sites

I've installed the latest release of AutoIT but I don't have the ftp files referenced. It there an additional download I need to get. I've searched for FTP.au3 but that's not on my system. Where do I get it?

From what I've seen in the WinInet.DLL reference, it is not possible to get a directory list using ftpcommand, it just won't support that type of return. To list a directory you need to call FtpFindFirstFile followed by calls to InternetFindNextFile until it returns an error, and then filtering the directories from the files.

So in other words a function to do this would have to be written. I'll look into trying one when I have the time.

On another note, when you use the ftpcommand function, open the session and connection as follows:

$ftpSes = _FTPOpen("Connection")

$intCon = _FTPConnect($ftpSes, "ftp.yourserver.com", "yourusername", "yourpassword")

Then use the connection handle ($intCon) for additional function calls, not the session handle ($ftpSes), as such:

$intComnd = _FTPCommand($intCon, 'PASV')

$intComnd = _FTPCommand($intCon, 'TYPE A')

Hope this helps

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0