用 Telnet 對 兩台 FTP Server 進行 PASV Mode 傳檔案 - PCZONE 討論區

返回   PCZONE 討論區 > ▲ -- 電 腦 軟 體 討 論 區 > -- 其 他 軟 體 討 論 版


PCZONE 討論區



通知

-- 其 他 軟 體 討 論 版 包括磁碟或檔案管理工具、掃毒軟體、解壓縮軟體、遠端遙控軟體、備份軟體、傳真軟體、手寫或語音等各種軟體使用經驗討論

會員
用 Telnet 對 兩台 FTP Server 進行 PASV Mode 傳檔案
去年也寫了一個沒有續傳,有給 purk,
但是我自己去年寫的不見了, 這個是昨天寫的我還加了續傳.
一個檔傳輸如果超過十分鐘下面的 Timeout 改大一點就可以了.

#! c:\perl\bin\perl.exe -w
print "Content-type: text/html \n\n";

use Net::Telnet ();
$username="bx2aa";
$passwd="test";
$username2="bx2aa";
$passwd2="test";
$port=21;
$port2=21;
$secs=10;
$host="192.168.1.2";
$host2="192.168.1.2";
$|=1;
$srcpath="user";
$destpath="./";
$filename="USER.rar";

#CLIENT FTP 1
$t = new Net::Telnet (Host => $host,Port => $port,Timeout => $secs);
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("USER $username");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("PASS $passwd");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("syst");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("type a");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("pwd");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("type i");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
$lines = $t->print("pasv");
print $lines."\n";
$lines = $t->getline;
print $pasv = $lines;
$lines = $t->print("cwd $srcpath");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";

#CLIENT FTP 2
$t2 = new Net::Telnet (Host => $host2,Port => $port2,Timeout => $secs);
print $lines."\n";
$lines = $t2->getline;
$lines = $t2->print("USER $username2");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("PASS $passwd2");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("syst");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("type a");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("pwd");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("pasv");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("cwd $destpath");
$lines = $t2->getline;
print $lines."\n";
$lines = $t2->print("SIZE $filename");
print $lines."\n";
$lines = $t2->getline;
$lines =~ s/.* (.*)$/\1/g;
print $rest=$lines."\n";
$lines = $t2->print("type i");
print $lines."\n";
$pasv = $1 if $pasv=~ m/.*\((.*?)\).*/s;
print $size=$lines."\n";
$lines = $t2->print("port $pasv");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
if ($rest ne "0") {
$lines = $t2->print("rest $rest");
print $lines."\n";
$lines = $t2->getline;
print $lines."\n";
}
$lines = $t2->print("stor $filename");
print $lines."\n";

#CLIENT FTP 1
if ($rest ne "0") {
$lines = $t->print("rest $rest");
print $lines."\n";
$lines = $t->getline;
print $lines."\n";
}
$lines = $t->print("retr $filename");
print $lines."\n";

#CLIENT FTP 2
$lines = $t2->getline(Timeout => "600");
print $lines."\n";

#CLIENT FTP 1
$lines = $t->getline(Timeout => "600");
print $lines."\n";

#CLIENT FTP 2
$lines = $t2->waitfor(Match => '/226/', Timeout => "600");
print $lines."\n";

#CLIENT FTP 1
$lines = $t->waitfor(Match => '/226/', Timeout => "600");
print $lines."\n";
$t->close;

#CLIENT FTP 2
$t2->close;

也可以放到 Apache Web Server 上 Run
使用方法
放到 Apache 的 CGI 目錄內
http://192.168.1.2/cgi-bin/Telnet.cgi
或是
C:\>perl Telnet.cgi

回覆


類似的主題
主題 主題作者 討論版 回覆 最後發表
FTP passive mode 在防火牆的相關設定 wenyue -- 網 路 技 術 版 4 2010-10-27 11:31 AM
【下載】Baby FTP Server, Quick 'n Easy FTP Server Lite FYI -- 軟 體 分 享 版 0 2009-01-19 06:23 PM
about telnet server rubin428 -- 網 路 軟 體 討 論 二 版 (網路其他軟體) 0 2001-12-29 10:45 AM
請問哪一套 Client FTP 軟體可以使用 telnet ? shyong -- 網 路 軟 體 討 論 二 版 (網路其他軟體) 2 2001-04-23 05:15 PM






 XML   RSS 2.0   RSS 
本站使用 vBulletin 合法版權程式
站務信箱 : [email protected]

本論壇所有文章僅代表留言者個人意見,並不代表本站之立場,討論區以「即時留言」方式運作,故無法完全監察所有即時留言,若您發現文章可能有異議,請 email :[email protected] 處理。