当使用ssh将备份文件转储到另一台服务器上时,为什么会出现"tcgetattr"错误? [英] why is the `tcgetattr` error seen when ssh is used for dumping the backup file on another server?
问题描述
我想将表备份转储到另一台服务器上,并且正在使用ssh来完成. 当我运行以下命令时,出现错误,但转储文件已复制到目标位置.
I want to dump a tables backup on another server and I am using ssh for doing it. when I run the below command, it gives an error but dump file is copied to destination.
mysqldump -u username -ppassword dbname tablename | ssh -t -t servers_username@domain_name 'cat > /tmp/bckp.sql';
tcgetattr:无效的参数
tcgetattr: Invalid argument
如果按 CTRL + c ,则会在错误消息后附加Killed by signal 2.
If I press CTRL+c then it appends error message with Killed by signal 2.
为什么会出现此错误?
推荐答案
使用ssh -t -t
或ssh -tt
强制进行伪终端分配时,我已经看到此错误.
I've seen this error when forcing pseudo-terminal allocation using ssh -t -t
or ssh -tt
.
tcgetattr
函数用于查找由文件描述符表示的伪终端的属性;它需要一个文件描述符和一个指向termios结构的指针来存储终端元数据.它从
The tcgetattr
function is used to look up the attributes of the pseudoterminal represented by a file descriptor; it takes a file descriptor and a pointer to a termios structure to store the terminal metadata in. It looks to me from the stub code in glibc that this error represents a null pointer for the termios
struct. I am not sure whether these same error handling semantics are in place for the platform-specific implementations of tcgetattr
.
如果您想抑制此错误,请像下面这样调用ssh
:
If you want to suppress this error, invoke ssh
like so:
ssh 2>/dev/null
这会将STDERR重定向到/dev/null
;使用此重定向调用时,您不会看到该错误.请注意,这将使用ssh
掩盖其他错误;您可能需要出于调试目的将其删除.
This will redirect STDERR to /dev/null
; you won't see the error when invoking with this redirection. Note that this will mask other errors with ssh
; you may need to remove this for debugging purposes.
这篇关于当使用ssh将备份文件转储到另一台服务器上时,为什么会出现"tcgetattr"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!