Jump to content
Sign in to follow this  
microbious

what is the best way to tell if you are connected to FTP server ?

Recommended Posts

microbious

what is the best way to tell if you are connected to FTP server ?

is it :

IF TCPRecv = <> "" then

or:

_FTPConnect = 1 then

?

When i use TCPRecv and if FTP server has welcome message, i will then be able to read welcome message and count it as connected. But if FTP server does not have welcome message then i am unable to tell if i am connected or not.

So maybe i need to somehow to be able to read what servers says in real time like LOG ?

Little confused here

Share this post


Link to post
Share on other sites
martin

what is the best way to tell if you are connected to FTP server ?

is it :

IF TCPRecv = <> "" then

or:

_FTPConnect = 1 then

?

When i use TCPRecv and if FTP server has welcome message, i will then be able to read welcome message and count it as connected. But if FTP server does not have welcome message then i am unable to tell if i am connected or not.

So maybe i need to somehow to be able to read what servers says in real time like LOG ?

Little confused here

When you connect the return from _FTPConnect will tell you if you connected successfully. If you want to check later to see if you are still connected then you could see what the return is from something like _FTPGetCurrentDir.

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
microbious

No that doest not work because even if FTP port is set to 21 but u are connecting to port 22 it will still say that u are connected but u are not connected to FTP .

U kinda connected to host but not to FTP so there must be another way to justify if connection was made correctly or not.

Share this post


Link to post
Share on other sites
Yashied

#Include <FTP.au3>

Global Const $Host = 'ftp.mozilla.org'
Global Const $Login = ''
Global Const $Password = ''
Global Const $Port = 21

Global $hFtp, $hSession

_FTP_Startup()
$hFtp = _FTP_Open('MyFtp')
_InternetSetOption($hFtp, $INTERNET_OPTION_CONNECT_TIMEOUT, 4000)
$hSession = _FTP_Connect($hFtp, $Host, $Login, $Password, $Port)
If @error Then
    MsgBox(0, '', 'Connect failed.')
Else
    MsgBox(0, '', 'Connect successful.')
EndIf
_FTP_Disconnect($hSession)
_FTP_Close($hFtp)
_FTP_Shutdown()

FTP.au3

Edited by Yashied

Share this post


Link to post
Share on other sites
microbious

this is not working.

If i specify different port number it will still be connected no matter what.

I used check current dir

$concheck = _FTPGetCurrentDir($FTPopen);check if curent directory recived
If $concheck = "" Then;if directory was not recived then
    SoundPlay (@TempDir & "/oops.wav",1);error sound
ElseIf $concheck = "/" then
SoundPlay (@TempDir & "/connected.wav",0); u are connected sound

works better. This way if directory listed then i can be 100% sure i connected and server responded by listing current directory.

Thanks

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.