ml.sock.pl mldonkey的cli版本控制台。
发表于 : 2012-04-12 14:44
直接在终端输入命令,操作mldonkey。
代码: 全选
● git diff HEAD^^^ ml.sock.pl
diff --git a/ml.sock.pl b/ml.sock.pl
index 4a3e13f..cfd0ea0 100755
--- a/ml.sock.pl
+++ b/ml.sock.pl
@@ -2,14 +2,15 @@
use IO::Socket::INET;
-my $sock = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => 4000) or
+my $sock = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => 4000) or
print "--命令: vd bw_toggle help kill etc.-->";
while(<>){
+last if /^quit|^exit/;
print $sock $_;
while(<$sock>){last if /^>/;}
print $_;
-while(<$sock>){last if /command-line/; print "$_\n";};
+while(<$sock>){last if /command-line/; print $_;};
print "--命令-->";
}
close $sock;
代码: 全选
● git df ml.sock.pl
diff --git a/ml.sock.pl b/ml.sock.pl
index cfd0ea0..6d5be2d 100755
--- a/ml.sock.pl
+++ b/ml.sock.pl
@@ -4,13 +4,22 @@ use IO::Socket::INET;
my $sock = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => 4000) or die "没找
-print "--命令: vd bw_toggle help kill etc.-->";
+print "--命令: vd bw_toggle s vr help kill etc.-->";
while(<>){
last if /^quit|^exit/;
print $sock $_;
+$vr=/vr/?1:0;
while(<$sock>){last if /^>/;}
print $_;
-while(<$sock>){last if /command-line/; print $_;};
+while(<$sock>){last if /command-line/;
+use Number::Format qw/format_bytes/;
+if($vr){
+s/]\ (\d)/] $1/; @_=split /\s{2,}/;
+next if $_[2]!~/^\d+$/; next if $_[2]<10000000;
+$_=$_[0].$_[1]." ".format_bytes($_[2])." ".substr($_[4],0,50)."\n";
+}
+print $_;
+}
print "--命令-->";
}
close $sock;