简体   繁体   中英

how to detect if FTP is working or not onremote machine?

I have 3 machines(A, B & C) connected to a Router. A,B & C are in same subnet. All these three machines are interconnected using STAF. I am using machine A as an FTP server & machine B as an FTP client. Using STAF command from machine CI am starting FTP program (TCL script) on machine B.

Now the question is, How C will know whether FTP traffic is flowing between A & B?

The ftp package allows you to specify a progress monitor callback in the ftp::Open command:

package require ftp

proc progressMessage {bytesSoFar} {
    puts "Transferred $bytesSoFar; looking good..."
}
set handle [ftp::Open $A $user $pass -progress progressMessage]

# Everything after this is just standard for the ftp package
if {$handle < 0} {
    error "could not connect"
}
if {![ftp::Get $handle $remoteFile $localFile]} {
    ftp::Close $handle
    error "could not transfer"
}
ftp::Close $handle
puts "Transfer completed"

This will print a message every time a chunk is transferred (the chunk size is configurable in the options to ftp::Open via the -blocksize option; it's 4096 by default). On modern networks, this is probably going to write messages very rapidly…

package require ftp
set handle [::ftp::Open $host $user $passwd]
if {$handle < 0} {
    error "Connection refused!"
    return 0
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM