简体   繁体   English

如何在远程计算机上检测FTP是否正常工作?

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

I have 3 machines(A, B & C) connected to a Router. 我具有连接到路由器3个机(A,B和C)。 A,B & C are in same subnet. A,B和C在同一子网中。 All these three machines are interconnected using STAF. 所有这三台机器都使用STAF互连。 I am using machine A as an FTP server & machine B as an FTP client. 我使用机器A作为FTP服务器,使用机器B作为FTP客户端。 Using STAF command from machine CI am starting FTP program (TCL script) on machine B. 使用计算机CI上的STAF命令在计算机B上启动FTP程序(TCL脚本)。

Now the question is, How C will know whether FTP traffic is flowing between A & B? 现在的问题是,C如何知道A和B之间是否有FTP通信流?

The ftp package allows you to specify a progress monitor callback in the ftp::Open command: ftp软件包允许您在ftp::Open命令中指定进度监视器回调:

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). 每次传输块时,都会打印一条消息(块大小可通过-blocksize选项在ftp::Open的选项中配置;默认为4096)。 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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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