Jump to content

download fiile via FTP command ??


Recommended Posts

hello all ... im trying to use ftp command get filename.exe to download it on my desktop

this is my code

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

Local $sServer = 'my server' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
Local $sUsername = 'user'
Local $sPass = 'password'

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
If @error Then
    MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
Else

_FTP_Command ( $hConn , "binary" )
_FTP_Command ( $hConn , "get myfile.exe" )


EndIf
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

this is how i can do it via batch on windows ...

@echo off
echo user username> ftpcmd.dat
echo password>> ftpcmd.dat
echo binary>> ftpcmd.dat
echo get myfile.exe>> ftpcmd.dat
 

 ftp -n -s:ftpcmd.dat myserver

but i dont need it in batch i need it via autoit can u help me please

 

 

Link to comment
Share on other sites

  • Moderators

@hani-dev since we don't have access to your secret server, can you please explain what isn't working for you? Are you getting an error? Is the file simply not downloading? Help us help you ;)

Some basic troubleshooting will help you at least narrow down where the error is happening:

  • Put in an If statement after _FTP_Open to catch any error
  • If there is no error there, are you getting an error at _FTP_Connect?
    • If so, what is the error number?
    • If not, are you entering the Else statement successfully (consolewrite will help)?
  • If you are entering the Else statement okay, are either of the_FTP_Command statements erroring out (error checking)?

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

4 hours ago, JLogan3o13 said:

@hani-dev since we don't have access to your secret server, can you please explain what isn't working for you? Are you getting an error? Is the file simply not downloading? Help us help you ;)

Some basic troubleshooting will help you at least narrow down where the error is happening:

  • Put in an If statement after _FTP_Open to catch any error
  • If there is no error there, are you getting an error at _FTP_Connect?
    • If so, what is the error number?
    • If not, are you entering the Else statement successfully (consolewrite will help)?
  • If you are entering the Else statement okay, are either of the_FTP_Command statements erroring out (error checking)?

 

yeah the file simply not downloading ... and i got this error 

"C:\Users\ev1\Desktop\Cpanel files\FTP.au3" (16) : ==> Incorrect number of parameters in function call.:
_FTP_Command ($hConn & "get qan.exe" )
^ ERROR
>Exit code: 1    Time: 1.317

i dont know where to put if im new in autoit :(

Edited by hani-dev
Link to comment
Share on other sites

5 hours ago, hani-dev said:

"C:\Users\ev1\Desktop\Cpanel files\FTP.au3" (16) : ==> Incorrect number of parameters in function call.:
_FTP_Command ($hConn & "get qan.exe" )
^ ERROR

Did you actually look at the error you get?
Did you compare this line to the line in the code you posted?
Did you see a difference?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

6 hours ago, jchd said:

Did you actually look at the error you get?
Did you compare this line to the line in the code you posted?
Did you see a difference?

ohh om sorry man this is my last try error ... for the first code i dont get any error :

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

Local $sServer = 'my server' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
Local $sUsername = 'user'
Local $sPass = 'password'

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
If @error Then
    MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
Else

_FTP_Command ( $hConn , "binary" )
_FTP_Command ( $hConn , "get myfile.exe" )


EndIf
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

i dont get any error ... and i dont get any downloaded file i dont know why 

Link to comment
Share on other sites

_FTP_FileGet() would certainly yield a more useful result.

Remainder: the help file isn't ransomware

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

i add this to my code :

_FTP_FileGet( $hConn , "bat.bat" , "C:\Users\ev\AppData\Roaming\bat.bat" )

but it's not work he put 0 byte file in AppData while the script is runing and when the script is finished the 0 byte file disappeared 

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...