Sign in to follow this  
Followers 0
zxzxzx

Func _FtpDos

20 posts in this topic

#1 ·  Posted (edited)

Author: LlyKil

_FTPDOS is Convenient & Result without spend more time

Added _FtpDosMkDir

Edited,Maybe this script already secure now

Code Here:

;  .........: _FTPDOS :.........
; AutoIt Version: 3.2.10.0
; Description ...: Use FTP Commands With Ms-Dos - Convenient & Result
; Author ........: LlyKil - 14 Years Old


;  .........: _FtpDosSend :.........
; Description        : Send Files
; $yourhost          : Your host
; $YourUser          : Host YourUserName
; $yourpassword      : Your Password
; $localfile         : May be you will understand if you see example :D
; Example            : _FtpDosSend("yourhost.com", "YourUser", "YourPassWord", "C:\YourFile.txt")
Func _FtpDosSend($yourhost, $YourUser, $yourpassword, $localfile)
    Opt("WinTitleMatchMode", 4)
    Run("ftp " & $yourhost, "", @SW_HIDE)
    WinWait(@systemdir & '\ftp.exe',"", @SW_HIDE)
    $HWND = WinGetHandle(@systemdir & '\ftp.exe')
    ControlSend($HWND, "", "", $YourUser & "{ENTER}")
    ControlSend($HWND, "", "", $yourpassword & "{ENTER}")
    ControlSend($HWND, "", "", "send " & $localfile & "{ENTER}")
    ControlSend($HWND, "", "", "bye{ENTER}")
EndFunc

;  .........: _FtpDosGet :.........
; Description        : Get Files
; $yourhost          : Your host
; $YourUser          : Host YourUserName
; $yourpassword      : Your Password
; $localfile         : May be you will understand if you see example :D
; $remotefile        : ________________________________________________
; Example            : _FtpDosGet("yourhost.com", "YourUser", "YourPassWord", "C:\YourFile.txt", "YourFile.txt")
Func _FtpDosGet($yourhost, $YourUser, $yourpassword, $localfile, $remotefile)
    Opt("WinTitleMatchMode", 4)
    Run("ftp " & $yourhost, "", @SW_HIDE)
    WinWait(@systemdir & '\ftp.exe',"", @SW_HIDE)
    $HWND = WinGetHandle(@systemdir & '\ftp.exe')
    ControlSend($HWND, "", "", $YourUser & "{ENTER}")
    ControlSend($HWND, "", "", $yourpassword & "{ENTER}")
    ControlSend($HWND, "", "", "get " & $localfile & " " & $remotefile & "{ENTER}")
    ControlSend($HWND, "", "", "bye{ENTER}")
EndFunc

;  .........: _FtpDosDel :.........
; Description        : Del Files
; $yourhost          : Your host
; $YourUser          : Host YourUserName
; $yourpassword      : Your Password
; $remotefile        : May be you will understand if you see example :D
; Example            : _FtpDosDel("yourhost.com", "YourUser", "YourPassWord", "YourFile.txt")
Func _FtpDosDel($yourhost, $YourUser, $yourpassword, $remotefile)
    Opt("WinTitleMatchMode", 4)
    Run("ftp " & $yourhost, "", @SW_HIDE)
    WinWait(@systemdir & '\ftp.exe',"", @SW_HIDE)
    $HWND = WinGetHandle(@systemdir & '\ftp.exe')
    ControlSend($HWND, "", "", $YourUser & "{ENTER}")
    ControlSend($HWND, "", "", $yourpassword & "{ENTER}")
    ControlSend($HWND, "", "", "del " & $remotefile & "{ENTER}")
    ControlSend($HWND, "", "", "bye{ENTER}")
EndFunc

;  .........: _FtpDosRen :.........
; Description        : Rename Files
; $yourhost          : Your host
; $YourUser          : Host YourUserName
; $yourpassword      : Your Password
; $remotefile        : May be you will understand if you see example :D
; $changefilename    : Name you want to change
; Example            : _FtpDosRen("yourhost.com", "YourUser", "YourPassWord", "YourFile.txt", "NameYouWant.txt")
Func _FtpDosRen($yourhost, $YourUser, $yourpassword, $remotefile, $changefilename)
    Opt("WinTitleMatchMode", 4)
    Run("ftp " & $yourhost, "", @SW_HIDE)
    WinWait(@systemdir & '\ftp.exe',"", @SW_HIDE)
    $HWND = WinGetHandle(@systemdir & '\ftp.exe')
    ControlSend($HWND, "", "", $YourUser & "{ENTER}")
    ControlSend($HWND, "", "", $yourpassword & "{ENTER}")
    ControlSend($HWND, "", "", "rename " & $remotefile & " " & $changefilename & "{ENTER}")
    ControlSend($HWND, "", "", "bye{ENTER}")
EndFunc

;  .........: _FtpDosMkDir :.........
; Description        : Make A Folder or Directory
; $yourhost          : Your host
; $YourUser          : Host YourUserName
; $yourpassword      : Your Password
; $dir               : Folder or Directory
; Example            : _FtpDosMkDir("yourhost.com", "YourUser", "YourPassWord", "YouDir")
Func _FtpDosMkDir($yourhost, $YourUser, $yourpassword, $dir)
    Opt("WinTitleMatchMode", 4)
    WinWait(@systemdir & '\ftp.exe',"", @SW_HIDE)
    $HWND = WinGetHandle(@systemdir & '\ftp.exe')
    ControlSend($HWND, "", "", $YourUser & "{ENTER}")
    ControlSend($HWND, "", "", $yourpassword & "{ENTER}")
    ControlSend($HWND, "", "", "mkdir " & $dir & "{ENTER}")
    ControlSend($HWND, "", "", "bye{ENTER}")
EndFuncoÝ÷ ØLZ^IéÝÊ«~)^°#­ E¶è±'§v«¨·*.®,µÊ&ªê-ªê-b«RÇ«ªê-ªê-b«=«,Zݪê-ªê-Ovb«)^·jºC£  塧h®­Ê«~)^±«­¢+Ù}ÑÁ½ÍÐ ÅÕ½Ðíå½ÕÉ¡½Íй½´ÅÕ½Ðì°ÅÕ½Ðíe½ÕÉUÍÈÅÕ½Ðì°ÅÕ½Ðíe½ÕÉAÍÍ]½ÉÅÕ½Ðì°ÅÕ½ÐíèÀäÈíe½ÕÉ¥±¹ÑáÐÅÕ½Ðì°ÅÕ½Ðíe½ÕÉ¥±¹ÑáÐÅÕ½ÐìoÝ÷ Ø7¥zײ¢êßW¬jëh×6_FtpDosDel("yourhost.com", "YourUser", "YourPassWord", "YourFile.txt")oÝ÷ Ù§jg²¢êßW¬jëh×6_FtpDosRen("yourhost.com", "YourUser", "YourPassWord", "YourFile.txt", "NameYouWant.txt")

_FtpDos.au3

Edited by zxzxzx

Share this post


Link to post
Share on other sites



Nice... I am being lazy here... Can you provide an example?

Thank You

Share this post


Link to post
Share on other sites

and what does this do? :D:o:P:):P:P:(:wub::blink:

Share this post


Link to post
Share on other sites

Nice... I am being lazy here... Can you provide an example?

Thank You

Maybe you should read _FtpDos.au3 becayse it had example :)

Share this post


Link to post
Share on other sites

OK, my bad... Thanks

Share this post


Link to post
Share on other sites

hm ... maybe i should make more function... xD

Share this post


Link to post
Share on other sites

Your script will not work if a cmd is running and type the username & password into it.

I don't use ftp and therefore have no use for this script but I'd rate this highly unsecure.

Maybe you should search for a ftp-program that can handle stdinwrite and stdoutread (maybe bundled one that comes with windows, I don't know.)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Your script will not work if a cmd is running and type the username & password into it.

I don't use ftp and therefore have no use for this script but I'd rate this highly unsecure.

Maybe you should search for a ftp-program that can handle stdinwrite and stdoutread (maybe bundled one that comes with windows, I don't know.)

Hm ... I don't know, but it work and faster

Did You test ?

Edited by zxzxzx

Share this post


Link to post
Share on other sites

Good script zxzxzx; an interesting alternative to the usual ftp UDFs.

@dabus.

I don't see how it is any less secure than other ftp methods posted. The password isn't displayed in the command prompt widow even if that were visible A packet sniffer could read the password but that's the same as most ftp methods used.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Good script zxzxzx; an interesting alternative to the usual ftp UDFs.

@dabus.

I don't see how it is any less secure than other ftp methods posted. The password isn't displayed in the command prompt widow even if that were visible A packet sniffer could read the password but that's the same as most ftp methods used.

xD, Thank

This script isn't my script. It was written by LlyKil. A boy only 14 years old :)

He is from Vietnam

Share this post


Link to post
Share on other sites

xD, Thank

This script isn't my script. It was written by LlyKil. A boy only 14 years old :)

He is from Vietnam

Oh yes, I see that now at the start of the first post.

In that case, good script LlyKil :P


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I just noted that - as far as I know - these lines

Run("ftp " & $yourhost, "", @SW_HIDE)
WinWait("classname=ConsoleWindowClass")
$HWND = WinGetHandle("classname=ConsoleWindowClass")

will wait for a @comspec/cmd-window to appear. If one's already present, it will not wait for the spawned one with the ftp but may choose an existing one. Am I wrong? :)

Edited by dabus

Share this post


Link to post
Share on other sites

I just noted that - as far as I know - these lines

Run("ftp " & $yourhost, "", @SW_HIDE)
WinWait("classname=ConsoleWindowClass")
$HWND = WinGetHandle("classname=ConsoleWindowClass")

will wait for a @comspec/cmd-window to appear. If one's already present, it will not wait for the spawned one with the ftp but may choose an existing one. Am I wrong? :)

I see what you mean. I think you are right.

So in this case maybe it would be safer to say

WinWait(@systemdir & '\ftp.exe')

What do you think?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I see what you mean. I think you are right.

So in this case maybe it would be safer to say

WinWait(@systemdir & '\ftp.exe')

What do you think?

Oh yeah ... thank

Maybe, The script already secure now .... xD

Edited by zxzxzx

Share this post


Link to post
Share on other sites

Thank all .....

Share this post


Link to post
Share on other sites

Your script will not work if a cmd is running and type the username & password into it.

I don't use ftp and therefore have no use for this script but I'd rate this highly unsecure.

Maybe you should search for a ftp-program that can handle stdinwrite and stdoutread (maybe bundled one that comes with windows, I don't know.)

$HWND = WinGetHandle(@systemdir & '\ftp.exe')

It sends to the window that wouldve just been made, With that title.

Not in any running cmd prompt.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

$HWND = WinGetHandle(@systemdir & '\ftp.exe')

It sends to the window that wouldve just been made, With that title.

Not in any running cmd prompt.

Exactly. The code was changed following that post by dabus and a bit of discussion because with the original code his comment was correct.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Exactly. The code was changed following that post by dabus and a bit of discussion because with the original code his comment was correct.

O. My mistake then, Lulz

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Exactly. The code was changed following that post by dabus and a bit of discussion because with the original code his comment was correct.

How to edit that script ?

That script was correct ?

Edited by zxzxzx

Share this post


Link to post
Share on other sites

Is there a good way to determine that the ftp actually worked?

I would like to delete the file after I send it, but only if it did actually login and ftp the file over.

If that can't be done, is there a way to at least make sure I have an internet connection before I start the FTP? In my case, that will be the most likely reason the ftp would fail.

Thanks,

Alan

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