Jump to content

FTP Example.au3 Error on running


Recommended Posts

:P Having Problems running this script. Here is the code:

$server = 'ftp.host.com'

$username = 'host\username'

$pass = 'mypassword'

$Open = _FTPOpen('MyFTP Control')

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

$Ftpp = _FtpGetFile($Conn, '/Update/contact.htm', 'c:\contact.htm')

$Ftpc = _FTPClose($Open)

When I run this the error message is

$Open =_FTPOpen('MyFTP Control')

$Open =^ERROR

Error: Unknown Function Name....

Newbie missing something simple.....

Cheers

Mike

Link to comment
Share on other sites

_FTPOpen is not a standard AU3's function but a UDF. You must download the UDF's file and #include it in your script to use _FTPOpen.

You will find everything needed here:

http://www.autoitscript.com/forum/index.php?showtopic=12473

Someones gonna have to straighten me out...

For someone who don't know what anyones talking about what Is a UDF...Secondly this is the page I originally downloaded the FTP Example.au3.

How do I use an include?

Thanks for the heads up....will eventually catch up...

Mike :P

Link to comment
Share on other sites

Hi again,

AutoIT has 2 types of functions. The standard ones (native support) and the User Defined Functions (UDF) which users write from time to time to enhance AU3's functionality.

For example a script which contains a UDF could be:

;start of script

TellMeMore()

;here the script ends execution and we put our custom functions

Func TellMeMore()
   MsgBox(0,"No","I won't tell you anything!")
EndFunc

UDFs however may be inside external .AU3 files to be used several times easily in your scripts. Some UDF files come with the (standard and beta) versions of AutoIT and some others may be downloaded by the users and used as desired. Note that the User Defined Functions usually start with an underscore before their name, i.e. _FTPOpen() just to know that this function is not a standard one and must be included.

Now about your problem do the following:

1). Download FTP.au3 from here. It contains the UDF you need.

2) Put that file in your AutoIT's 3 include folder. It is usually "C:\Program Files\AutoIt3\Include" if you run the standard version or "C:\Program Files\AutoIt3\beta\Include" if you run the beta one.

3) Edit and test this example:

#include <FTP.au3>; This line includes all the FTP functions you need. Open this file to see which functions contains exactly.

$server = 'ftp.example.com'
$username = 'secretusers'
$pass = 'hiddenpass'

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/somedir/Example.exe')
$Ftpc = _FTPClose($Open)

I hope it's clear now.

Edited by erebus
Link to comment
Share on other sites

One more thing....When I compile the script as an exe I presume the include file will be included and I won't have to take this with the executable?

An Yes I appreciate your time and help.... A journey starts with the first step..and so on...

Thanks

Mike

Hi again,

AutoIT has 2 types of functions. The standard ones (native support) and the User Defined Functions (UDF) which users write from time to time to enhance AU3's functionality.

For example a script which contains a UDF could be:

;start of script

TellMeMore()

;here the script ends execution and we put our custom functions

Func TellMeMore()
   MsgBox(0,"No","I won't tell you anything!")
EndFunc

UDFs however may be inside external .AU3 files to be used several times easily in your scripts. Some UDF files come with the (standard and beta) versions of AutoIT and some others may be downloaded by the users and used as desired. Note that the User Defined Functions usually start with an underscore before their name, i.e. _FTPOpen() just to know that this function is not a standard one and must be included.

Now about your problem do the following:

1). Download FTP.au3 from here. It contains the UDF you need.

2) Put that file in your AutoIT's 3 include folder. It is usually "C:\Program Files\AutoIt3\Include" if you run the standard version or "C:\Program Files\AutoIt3\beta\Include" if you run the beta one.

3) Edit and test this example:

#include <FTP.au3>; This line includes all the FTP functions you need. Open this file to see which functions contains exactly.

$server = 'ftp.example.com'
$username = 'secretusers'
$pass = 'hiddenpass'

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, 'C:\WINDOWS\Notepad.exe', '/somedir/Example.exe')
$Ftpc = _FTPClose($Open)

I hope it's clear now.

Link to comment
Share on other sites

I just Downloaded another peice of script for the FTP.au3 which includes the _FTPGetFile function and added it to the FTP.au3. Just for all those needing to Get a file from an FTP....Tested and worked fine.

All Credit to go to W0uter and also Dickb for the _FTPGetile addon...

Thanks also to erebus to help me out with some fundamentals....

Mike

One more thing....When I compile the script as an exe I presume the include file will be included and I won't have to take this with the executable?

An Yes I appreciate your time and help.... A journey starts with the first step..and so on...

Thanks

Mike

FTP.au3

FTP_GETFile_Example.au3

Edited by hispeed_mike
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...