我想获得所有目标设备的IP,其中我的数据传输使用rsync无法完成(甚至启动),因为这些设备未连接到互联网或断开数据传输…
我的实际问题是:
rsync -t Desktop / sony.pdf home@a.b.c.d:
ssh:连接到主机a.b.c.d端口22:没有到主机的路由
我想要所有这样的IP的列表,数据传输不能被插入…
所有IP的列表,如’a.b.c.d’
我在perl(命令行)中做这个工作:
原文链接:https://www.f2er.com/bash/386228.html# perl -ne ' ($conn{$2}->{"ip"},$conn{$2}->{"started"})=($3,$1) if /^(.{15}).*rsyncd\[(\d+)\]:\sconnect.*\((\d+\.\d+\.\d+\.\d+)\)/; $conn{$2}->{"closed"}=$1 if /(.{15}).*rsyncd\[(\d+)\]:\ssent\s.*\stotal/; END { print "Good:\n"; map{ printf "%s %-16s %s\n",$conn{$_}->{"started"},$conn{$_}->{"ip"},$conn{$_}->{"closed"} if $conn{$_}->{"closed"}; } sort { $conn{$a}->{"started"} cmp $conn{$b}->{"started"} } keys %conn; print "Unterminated:\n"; map{ printf "%s %s\n",$conn{$_}->{"ip"}; } sort { $conn{$a}->{"started"} cmp $conn{$b}->{"started"} } grep { ! defined $conn{$_}->{"closed"} } keys %conn; }' < /var/log/daemon.log
这可以产生如下结果:
Good: Apr 28 08:12:01 127.0.0.1 Apr 28 08:15:35 Apr 28 08:27:01 192.168.1.36 Apr 28 08:28:04 Apr 28 08:42:01 127.0.0.1 Apr 28 08:42:13 Apr 28 08:57:01 192.168.1.36 Apr 28 08:57:16 Apr 28 09:12:01 127.0.0.1 Apr 28 09:12:28 Apr 28 09:27:01 192.168.1.36 Apr 28 09:27:13 Apr 28 09:42:01 127.0.0.1 Apr 28 09:42:09 Apr 28 09:57:02 192.168.1.36 Apr 28 09:57:16 Apr 28 10:12:01 127.0.0.1 Apr 28 10:12:32 Apr 28 10:27:01 192.168.1.36 Apr 28 10:27:12 Apr 28 10:42:01 127.0.0.1 Apr 28 10:42:14 Apr 28 10:57:01 192.168.1.36 Apr 28 10:57:13 Apr 28 11:27:01 192.168.1.36 Apr 28 11:28:01 Apr 28 11:42:01 127.0.0.1 Apr 28 11:44:32 Apr 28 11:57:02 192.168.1.36 Apr 28 11:58:43 Apr 28 12:12:01 127.0.0.1 Apr 28 12:12:27 Apr 28 12:27:01 192.168.1.36 Apr 28 12:28:48 Apr 28 12:42:01 127.0.0.1 Apr 28 12:42:13 Apr 28 12:57:01 192.168.1.36 Apr 28 12:57:56 Unterminated: Apr 28 11:12:01 127.0.0.1