简体   繁体   English

如何抑制“stty:'标准输入':设备的 ioctl 不合适”错误

[英]How to supress the “stty: 'standard input': Inappropriate ioctl for device” error

Problem问题

Basically I've have working with a Python script that emulate a real terminal.基本上我已经使用了模拟真实终端的 Python 脚本。 So, I was trying some tools for Linux, and when I try to use some tools the STDOUT comes with:所以,我正在尝试一些用于 Linux 的工具,当我尝试使用一些工具时,STDOUT 附带:

stty: 'standard input': Inappropriate ioctl for device" message error stty:“标准输入”:设备的 ioctl 不合适”消息错误

Question问题

Is possible to suppress this error message without the .replace() ?是否可以在没有.replace()的情况下抑制此错误消息?

Script脚本

import subprocess
import os

f = open('output.txt', 'w')
proc = subprocess.Popen('/bin/bash', stderr=subprocess.STDOUT, stdin=subprocess.PIPE, stdout=f, shell=True)
while True:
    command = input('Type:')
    if command == "cls":
        open('output.txt', 'w').close()
        os.system('cls' if os.name == 'nt' else 'clear')
    else:
        command = command.encode('utf-8') + b'\n'
        proc.stdin.write(command)
        proc.stdin.flush()
        with open('output.txt', 'r+') as ff:
            print(ff.read())

Error example错误示例

$ python3 script.py $ python3脚本.py

Type: msfconsole类型:msfconsole

*wait a few seconds for load the banner *等待几秒钟以加载横幅

Type: banner类型:横幅

   =[ metasploit v6.0.15-dev                          ]
  • -- --=[ 2071 exploits - 1123 auxiliary - 352 post ] -- --=[ 2071 漏洞利用 - 1123 辅助 - 352 帖子]
  • -- --=[ 592 payloads - 45 encoders - 10 nops ] -- --=[ 592 个有效载荷 - 45 个编码器 - 10 个 nops ]
  • -- --=[ 7 evasion ] -- --=[7闪避]

Metasploit tip: Use the edit command to open the currently active module in your editor Metasploit 提示:使用 edit 命令在编辑器中打开当前活动的模块

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

stty: 'standard input': Inappropriate ioctl for device stty:“标准输入”:设备的 ioctl 不合适

msf6> msf6>

Type:类型:

You can add other exceptions, like you did for cls :您可以添加其他例外,就像您为cls所做的那样:

    elif command == "stty" or command == "...":
        os.system(command)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 崇高的tset:标准错误:设备的ioctl不适当 - Sublime tset: standard error: Inappropriate ioctl for device Pexpect和PyCharm - 适用于设备的ioctl - Pexpect and PyCharm - Inappropriate ioctl for device OpenCV3错误:“无法停止流:设备的不适当的ioctl” - OpenCV3 error: “Unable to stop the stream: Inappropriate ioctl for device” IOError:[Errno 25] 设备的 ioctl 不合适 - IOError: [Errno 25] Inappropriate ioctl for device opencv无法阻止流:设备的ioctl不合适 - opencv Unable to stop the stream: Inappropriate ioctl for device 在Python中运行ioctl会返回ENOTTY-设备不适合的ioctl - Running ioctl in Python returns ENOTTY - inappropriate ioctl for device 键盘和弦代码的错误消息:termios.error: (25, 'Inappropriate ioctl for device') - Error message for keyboard-chord code: termios.error: (25, 'Inappropriate ioctl for device') 詹金斯的pipenv shell返回问题termios.error:(25,'不合适的设备ioctl') - pipenv shell in Jenkins return the issue termios.error: (25, 'Inappropriate ioctl for device') X 服务器“localhost:10.0”上的 matplot lib“致命 IO 错误 25(设备的 ioctl 不合适)” - matplot lib "fatal IO error 25 (Inappropriate ioctl for device) on X server "localhost:10.0" 当在具有PowerCLI的VM上运行时,pexpect的interact()报告“不适当的设备ioctl” - pexpect's interact() reported “Inappropriate ioctl for device” when running on a VM with PowerCLI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM