地铁在STDOUT的结果?

我正在尝试mtr (我的traceroute)为教育目的。 然而,我不能pipe理它直接打印结果到stdout ,这是相当令人不安的。 默认情况下,它会打开一个GTK窗口,在其中打印结果。 如果我使用-t选项,我可以强制它在terminal中使用ncurses 。 但是这根本没有帮助。

有没有办法使用这个程序“UNIX的方式”? 我只想要结果出来,没有花哨的额外!

我已经在当前的debian wheezy上安装了mtr软件包。

 $ mtr --version mtr 0.82 

尝试在Debian上使用mtr-tiny 软件包 ,让它在没有GTK或ncurses的情况下工作。

mtr-tiny编译时不支持X,节省磁盘空间。

 root@mail:~# apt-cache show mtr-tiny Package: mtr-tiny Priority: optional Section: net Installed-Size: 120 Maintainer: Robert Woodcock <[email protected]> Architecture: amd64 Source: mtr Version: 0.75-2 Replaces: mtr Depends: libc6 (>= 2.7-1), libncurses5 (>= 5.6+20071006-3) Conflicts: mtr, suidmanager (<< 0.50) Filename: pool/main/m/mtr/mtr-tiny_0.75-2_amd64.deb Size: 40740 MD5sum: 46cbf5da3e22772d34a7a696cc6648a5 SHA1: 40d6427a48c0dac7b6e31e0a9592ef6381445001 SHA256: 9a32f07375e09f11109cd207f8875647bd3f3b88170c071f3a13aca614182e15 Description: Full screen ncurses traceroute tool mtr combines the functionality of the 'traceroute' and 'ping' programs in a single network diagnostic tool. . As mtr starts, it investigates the network connection between the host mtr runs on and a user-specified destination host. After it determines the address of each network hop between the machines, it sends a sequence ICMP ECHO requests to each one to determine the quality of the link to each machine. As it does this, it prints running statistics about each machine. . mtr-tiny is compiled without support for X and conserves disk space. Tag: interface::text-mode, network::scanner, protocol::ip, role::program, scope::utility, uitoolkit::ncurses, use::checking 

打开terminal/控制台窗口并使用-r-cn )。 这将做你想要的。 或者ssh到服务器。

Ubuntu – mtr 0.85

  mtr -c 1 -r google.com Start: Sun Jan 26 15:19:11 2014 HOST: host1 Loss% Snt Last Avg Best Wrst StDev 1.|-- firewall 0.0% 1 0.8 0.8 0.8 0.8 0.0 2.|-- 192.168.1.254 0.0% 1 1.8 1.8 1.8 1.8 0.0 3.|-- 217.32.143.44 0.0% 1 8.5 8.5 8.5 8.5 0.0 4.|-- 217.32.143.110 0.0% 1 8.3 8.3 8.3 8.3 0.0 5.|-- 213.120.158.242 0.0% 1 11.4 11.4 11.4 11.4 0.0 6.|-- 31.55.165.171 0.0% 1 12.6 12.6 12.6 12.6 0.0 7.|-- 31.55.165.109 0.0% 1 12.1 12.1 12.1 12.1 0.0 8.|-- 31.55.167.5 0.0% 1 11.3 11.3 11.3 11.3 0.0 9.|-- 31.55.167.151 0.0% 1 11.2 11.2 11.2 11.2 0.0 

CentOS mtr版本0.75

 [iain@host ~]$ sudo mtr -c1 -r www.google.com HOST: host Loss% Snt Last Avg Best Wrst StDev 1. 2001:470:1f05:6e9::1 0.0% 1 0.6 0.6 0.6 0.6 0.0 2. Iain-1.tunnel.tserv . 0.0% 1 25.3 25.3 25.3 25.3 0.0 3. ge4-8.core1.lon1.he.net 0.0% 1 21.3 21.3 21.3 21.3 0.0 4. 2001:4860:1:1:0:1b1b:0:5 0.0% 1 21.1 21.1 21.1 21.1 0.0 5. 2001:4860::1:0:3067 0.0% 1 21.5 21.5 21.5 21.5 0.0 6. 2001:4860::8:0:5bb9 0.0% 1 21.2 21.2 21.2 21.2 0.0 7. 2001:4860::8:0:51a0 0.0% 1 27.6 27.6 27.6 27.6 0.0 8. 2001:4860::8:0:5039 0.0% 1 36.3 36.3 36.3 36.3 0.0 9. 2001:4860::1:0:4ca2 0.0% 1 33.9 33.9 33.9 33.9 0.0 10. 2001:4860:0:1::6eb 0.0% 1 34.2 34.2 34.2 34.2 0.0 11. fra02s17-in-x10.1e100.net 0.0% 1 34.4 34.4 34.4 34.4 0.0 

这也可以redirect到一个文件。

你可以添加一个别名。 编辑文件/etc/bash.bashrc并在最后添加:

 alias mtr="mtr -t" 

重新启动并尝试。