Jump to content

how to judge the ftp server is open?


 Share

Recommended Posts

i use ftp.au3 to judge.

=====================================

for example ,ftp://123:123@10.2.72.246:21

#include <ftp.au3>

$ftp_ip = "10.2.72.246"

$ftp_name ="123"

$ftp_pass = "123"

$ftp_ctrlport = "21"

$dllhandle = DllOpen('wininet.dll')

$z_ftpOpen = _FTPOpen('MyFTP_Control')

$z_ftpConn = _FTPConnect($z_ftpOpen, $ftp_ip, $ftp_name, $ftp_pass, $ftp_ctrlport)

If @error Then

MsgBox(0, "ftp", "the FTP is closed or full of users", 5)

$z_ftpClos = _FTPClose($z_ftpOpen)

Else

MsgBox(0, "FTP", "the FTP can be logged in", 5)

$z_ftpClos = _FTPClose($z_ftpOpen)

EndIf

=====================================

but it can judge whether the ftp is closed or it is full of users.

if the ftp is closed ,it will takes a long time to get the result.

how to solve the two problems?

thanks!

Link to comment
Share on other sites

i use ftp.au3 to judge.

=====================================

for example ,ftp://123:123@10.2.72.246:21

#include <ftp.au3>

$ftp_ip = "10.2.72.246"

$ftp_name ="123"

$ftp_pass = "123"

$ftp_ctrlport = "21"

$dllhandle = DllOpen('wininet.dll')

$z_ftpOpen = _FTPOpen('MyFTP_Control')

$z_ftpConn = _FTPConnect($z_ftpOpen, $ftp_ip, $ftp_name, $ftp_pass, $ftp_ctrlport)

If @error Then

MsgBox(0, "ftp", "the FTP is closed or full of users", 5)

$z_ftpClos = _FTPClose($z_ftpOpen)

Else

MsgBox(0, "FTP", "the FTP can be logged in", 5)

$z_ftpClos = _FTPClose($z_ftpOpen)

EndIf

=====================================

but it can judge whether the ftp is closed or it is full of users.

if the ftp is closed ,it will takes a long time to get the result.

how to solve the two problems?

thanks!

I don't know but I would expect that you can't tell. Whichever problem exists there will be no reply from the ftp server so maybe that's all you can say.

It is possible that a call to InternetGetLastResponseInfo will give you the reason for the failure though.

I expect the msbox lines were put in when I was playing with this once. I don't know where the function comes from or who wrote it.

; Use InternetGetLastResponseInfo when GetLastError returns ERROR_INTERNET_EXTENDED_ERROR.
Func _InternetGetLastResponseInfo($LeHD,ByRef $LstErr,ByRef $ErrStrg)
    
        msgbox(0,'getting last response info','')
#cs 
    $Res = DllCall ("wininet.dll", "int", "InternetGetLastResponseInfo",  "str", "",  "str", "", "int", 0 )

; The empty strings gets filled by the function, so we can get their values
$LstErr = $Res[1]
$ErrStrg = $Res[2]
    
#ce
    
    $struct_Buffer = DllStructCreate("char[300]");

    $erBuf = DllStructCreate('int')
    $szBuf = DllStructCreate('int')
    DllStructSetData($szBuf,1,300)
    $Res = DllCall($LeHD,'int', 'InternetGetLastResponseInfo','int*',DllStructGetPtr($erBuf),'ptr',DllStructGetPtr($struct_Buffer),'int*',DllStructGetPtr($szBuf)
    $LstErr = DllStructGetData($erBuf, 1)
    $ErrStrg = DllStructGetData($struct_Buffer, 1)
    msgbox(0,'size requested is',DllStructGetData($szBuf,1))
    msgbox(0,'LstErr = ' & $LstErr,'Error message = ' & $ErrStrg)
    if @error = 1 then msgbox(0,'dll failed','')
        msgbox(0,'ftpplus 750. err string is',$ErrStrg)
    $rreess = ''
    for $rr = 0 to UBound($res)- 1
        $rreess = $rreess & $res[$rr] & @CRLF
    Next
    msgbox(0,'From lastresponse',$rreess)

    return $Res;[0]
EndFunc
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.
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...