我想静静地通过脚本测试X11是否正常工作。
即使使用(例如)xset q > /dev/null 2>&1
我追踪了它,似乎没有被xset写入。我也跟踪了相关的sshd,它似乎也没有写它。
xp,xdpyinfo和https://github.com/tradewright/ibapi-tools/blob/master/ContractInspector/readme.md处的测试程序都输出此无用的错误消息。实际上,vim也是如此。但是“ ls”不是。我也尝试过:script -e -c 'xset q' /dev/null > /dev/null 2>&1
...但是即使输出错误消息。
我需要做什么以使此过激的错误消息静音?
谢谢!
PS:这是xset q的痕迹:
20878 execve("/usr/bin/xset", ["xset", "q"], 0x7ffe3e91cfe0 /* 33 vars */) = 0
20878 brk(NULL) = 0x563d8a664000
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=141841, ...}) = 0
20878 mmap(NULL, 141841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19ac118000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXmuu.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\23\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14528, ...}) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac144000
20878 mmap(NULL, 2109592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19abd10000
20878 mprotect(0x7f19abd13000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19abf12000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19abf12000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXext.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\2205\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=73640, ...}) = 0
20878 mmap(NULL, 2169496, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19abaf8000
20878 mprotect(0x7f19abb09000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19abd08000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7f19abd08000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libX11.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\207\1\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=1277384, ...}) = 0
20878 mmap(NULL, 3374392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab7c0000
20878 mprotect(0x7f19ab8f3000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19abaf3000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x133000) = 0x7f19abaf3000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
20878 mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab3c8000
20878 mprotect(0x7f19ab5af000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19ab7af000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f19ab7af000
20878 mmap(0x7f19ab7b5000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19ab7b5000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libxcb.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\261\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=162232, ...}) = 0
20878 mmap(NULL, 2257576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab1a0000
20878 mprotect(0x7f19ab1c6000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19ab3c6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7f19ab3c6000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
20878 mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aaf98000
20878 mprotect(0x7f19aaf9b000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19ab19a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19ab19a000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXau.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14456, ...}) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac142000
20878 mmap(NULL, 2109720, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aad90000
20878 mprotect(0x7f19aad92000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19aaf92000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19aaf92000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXdmcp.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\21\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=22616, ...}) = 0
20878 mmap(NULL, 2117760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aab88000
20878 mprotect(0x7f19aab8d000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aad8c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f19aad8c000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbsd.so.0", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P4\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=80104, ...}) = 0
20878 mmap(NULL, 2179152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa970000
20878 mprotect(0x7f19aa983000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aab82000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7f19aab82000
20878 mmap(0x7f19aab84000, 80, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aab84000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\"\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=31680, ...}) = 0
20878 mmap(NULL, 2128864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa768000
20878 mprotect(0x7f19aa76f000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa96e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f19aa96e000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
20878 mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa548000
20878 mprotect(0x7f19aa562000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa761000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f19aa761000
20878 mmap(0x7f19aa763000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aa763000
20878 close(3) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac13d000
20878 mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac115000
20878 arch_prctl(ARCH_SET_FS, 0x7f19ac115740) = 0
20878 mprotect(0x7f19ab7af000, 16384, PROT_READ) = 0
20878 mprotect(0x7f19aa761000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aa96e000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aab82000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aad8c000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aaf92000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ab19a000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ab3c6000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abaf3000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abd08000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abf12000, 4096, PROT_READ) = 0
20878 mprotect(0x563d8872f000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ac13f000, 4096, PROT_READ) = 0
20878 munmap(0x7f19ac118000, 141841) = 0
20878 set_tid_address(0x7f19ac115a10) = 20878
20878 set_robust_list(0x7f19ac115a20, 24) = 0
20878 rt_sigaction(SIGRTMIN, {sa_handler=0x7f19aa54dcb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f19aa55a890}, NULL, 8) = 0
20878 rt_sigaction(SIGRT_1, {sa_handler=0x7f19aa54dd50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f19aa55a890}, NULL, 8) = 0
20878 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
20878 prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
20878 brk(NULL) = 0x563d8a664000
20878 brk(0x563d8a685000) = 0x563d8a685000
20878 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
20878 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20878 close(3) = 0
20878 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
20878 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20878 close(3) = 0
20878 openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=529, ...}) = 0
20878 read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 529
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=304, ...}) = 0
20878 openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
20878 read(3, "# The \"order\" line is only used "..., 4096) = 92
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 futex(0x7f19ab7b7ba4, FUTEX_WAKE_PRIVATE, 2147483647) = 0
20878 openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=304, ...}) = 0
20878 read(3, "# Dynamic resolv.conf(5) file fo"..., 4096) = 304
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 uname({sysname="Linux", nodename="zareason-limbo", ...}) = 0
20878 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=141841, ...}) = 0
20878 mmap(NULL, 141841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19ac0f0000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P#\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=47568, ...}) = 0
20878 mmap(NULL, 2168632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa330000
20878 mprotect(0x7f19aa33b000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa53a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7f19aa53a000
20878 mmap(0x7f19aa53c000, 22328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aa53c000
20878 close(3) = 0
20878 mprotect(0x7f19aa53a000, 4096, PROT_READ) = 0
20878 munmap(0x7f19ac0f0000, 141841) = 0
20878 openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=403, ...}) = 0
20878 read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tza"..., 4096) = 403
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 3
20878 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
20878 setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
20878 connect(3, {sa_family=AF_INET, sin_port=htons(6013), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
20878 getpeername(3, {sa_family=AF_INET, sin_port=htons(6013), sin_addr=inet_addr("127.0.0.1")}, [124->16]) = 0
20878 uname({sysname="Linux", nodename="zareason-limbo", ...}) = 0
20878 access("/home/dstromberg/.Xauthority", R_OK) = 0
20878 openat(AT_FDCWD, "/home/dstromberg/.Xauthority", O_RDONLY) = 4
20878 fstat(4, {st_mode=S_IFREG|0600, st_size=827, ...}) = 0
20878 read(4, "\1\0\0\16zareason-limbo\0\0010\0\22MIT-MAGIC"..., 4096) = 827
20878 read(4, "", 4096) = 0
20878 close(4) = 0
20878 getsockname(3, {sa_family=AF_INET, sin_port=htons(37214), sin_addr=inet_addr("127.0.0.1")}, [124->16]) = 0
20878 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
20878 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
20878 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
20878 poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
20878 writev(3, [{iov_base="l\0\v\0\0\0\22\0\20\0\0\0", iov_len=12}, {iov_base="", iov_len=0}, {iov_base="MIT-MAGIC-COOKIE-1", iov_len=18}, {iov_base="\0\0", iov_len=2}, {iov_base="\256b\245\317f\262\25\254\27\365!H\212\3316J", iov_len=16}, {iov_base="", iov_len=0}], 6) = 48
20878 recvfrom(3, 0x563d8a6660e0, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
20878 poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN|POLLERR|POLLHUP}])
20878 recvfrom(3, 0x563d8a6660e0, 8, 0, NULL, NULL) = -1 ECONNRESET (Connection reset by peer)
20878 shutdown(3, SHUT_RDWR) = -1 ENOTCONN (Transport endpoint is not connected)
20878 close(3) = 0
20878 write(2, "xset: unable to open display \"l"..., 47) = 47
20878 exit_group(1) = ?
20878 +++ exited with 1 +++
这是-a xset类型:
$ type -a xset
below cmd output started 2019 Sun Jun 30 07:49:33 AM PDT
xset is /usr/bin/xset
无需重定向即可运行,以显示消息的顺序:
$ xset q
below cmd output started 2019 Sun Jun 30 08:03:24 AM PDT
connect /tmp/.X11-unix/X1: No such file or directory
xset: unable to open display "localhost:13.0"
为响应melpomene的评论,我建立了一个完全没有启动文件的测试帐户。然后,我对它ssh -Y进行了sudo操作,并得到了与上述相同的错误消息。
我一直在gnome-terminal进行测试。我刚刚尝试了konsole,又收到了令人反感的错误消息。
我刚刚尝试过跟踪openssh客户端;它只产生了一次字符串“ connect”,看起来并不相关(除了连接到ssh服务器)。
我一直在Linux Mint 19.1系统上进行专门测试。我只是在新安装的Debian 9.9系统上尝试过,并得到了相同的结果。
要复制的步骤:
通过这三个简单的步骤,您可能会看到令人讨厌的错误消息。
答案 0 :(得分:3)
这很容易理解和复制,但是有很多活动的部分。
我们通过X转发到一个远程机器。 此ssh进程必须可以在本地访问运行中的X服务器。在这里,我们将以一个玩笑$DISPLAY
开始
(local) $ DISPLAY=:87 ssh -Y remote
Warning: No xauth data; using fake authentication data for X11 forwarding
Warning
表示 ssh 无法在本地联系正在工作的X服务器。
在远程上$DISPLAY
不是:87
(remote) $ echo $DISPLAY
(remote) localhost:11.0
这是 ssh 的-Y
的神奇之处,以及它的X11代理如何工作。
我们在远程运行命令以尝试连接到$DISPLAY
:
(remote) $ xset -q
connect /tmp/.X11-unix/X99: No such file or directory
xset: unable to open display "localhost:11.0"
这是你的问题:
(remote) $ xset -q >/dev/null 2>&1
connect /tmp/.X11-unix/X99: No such file or directory
xset 正在打印unable
错误消息,
并已被重定向。
但是connect
错误消息是从 ssh 发出的。
请记住, xset 在 remote 上运行,
当 ssh 在 local 上运行时。
在运行 ssh 之前,您需要先在 local 上验证$DISPLAY
。
您可以通过多种方式使 ssh 安静下来, 但我不喜欢丢弃错误消息。 一种方法是减少错误详细程度:
(local) $ DISPLAY=:87 ssh -Y -o LogLevel=FATAL remote 'xset -q &>/dev/null'
有关 ssh 设置的列表,请参见 man ssh_config 。