linux - bash 本身生成的静音错误
问题描述
我需要有一个安排,其中有时bash -ic
在没有 pty 的情况下执行。我必须使用 -i(需要运行 .bashrc)并且我必须没有 pty(通过 ssh 传输标准输入)。但是,我不想看到这个:
bash: cannot set terminal process group (20605): Inappropriate ioctl for device
bash: no job control in this shell
我只能用 过滤掉它2> >(grep -v 'bash: ')
,但我更愿意屏蔽 bash 本身,因为该过滤器也适用于该 bash 运行的任何命令 (-c)。
重申一下,我正在寻找一种方法来消除与 bash 本身相关的警告 - 而不是它执行的脚本。
如果你想重现它,试试这个:
$ echo hello |ssh -t you@<linuxHost> bash -ic cat -
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
hello
解决方案
使用ssh -tt
.
引用ssh
手册:
-t
强制伪终端分配。这可用于在远程机器上执行任意基于屏幕的程序,这非常有用,例如在实现菜单服务时。多个-t
选项强制 tty 分配,即使 ssh 没有本地 tty。
推荐阅读
- javascript - 在 PHP 中的标头之前运行脚本消息
- google-drive-api - 导出 Google Workspace 文档时出现“413 请求实体太大”
- tensorflow - tensorflow 急切执行在运行时发生变化
- github-classroom - 如何自动将自动评分文件复制到学生的存储库中?
- javascript - 使用 Chart.js 显示比赛单圈时间和位置
- python - python中的频率与总数条形图
- installation - magento 设置错误:升级 - 元素“路由”:缺少子元素。预期是(资源)
- javascript - onClick 方法适用于第二次点击。但它应该在第一次点击时起作用
- excel - 所有行中的 Excel 查找值,而不仅仅是第一个匹配项
- elasticsearch - RestHighLevelClient 弹性搜索 Java 客户端需要更多时间进行搜索查询