求靠谱点的获取ttyshell的方法,最好是通过c或者perl的。
Linux目前已知的获取ttyshell的方法,一般有两种。
一是通过python:
python -c 'import pty; pty.spawn("/bin/sh")'
但是目标机器是64位系统,提示错误:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "/usr/lib64/python2.4/pty.py", line 153, in spawn
pid, master_fd = fork()
File "/usr/lib64/python2.4/pty.py", line 107, in fork
master_fd, slave_fd = openpty()
File "/usr/lib64/python2.4/pty.py", line 29, in openpty
master_fd, slave_name = _open_terminal()
File "/usr/lib64/python2.4/pty.py", line 70, in _open_terminal
raise os.error, 'out of pty devices'
OSError: out of pty devices
二是通过shell脚本:
#!/usr/bin/expect
# Spawn a shell, then allow the user to interact with it.
# The new shell will have a good enough TTY to run tools like ssh, su and login
spawn sh
interact
但是expect不存在。
求其他方法。
一是通过python:
python -c 'import pty; pty.spawn("/bin/sh")'
但是目标机器是64位系统,提示错误:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "/usr/lib64/python2.4/pty.py", line 153, in spawn
pid, master_fd = fork()
File "/usr/lib64/python2.4/pty.py", line 107, in fork
master_fd, slave_fd = openpty()
File "/usr/lib64/python2.4/pty.py", line 29, in openpty
master_fd, slave_name = _open_terminal()
File "/usr/lib64/python2.4/pty.py", line 70, in _open_terminal
raise os.error, 'out of pty devices'
OSError: out of pty devices
二是通过shell脚本:
#!/usr/bin/expect
# Spawn a shell, then allow the user to interact with it.
# The new shell will have a good enough TTY to run tools like ssh, su and login
spawn sh
interact
但是expect不存在。
求其他方法。
评论7次
BS牛现身了
我肉。BS妞献身了
我日,包子肿现身了
不错的经验,如果可以分享下咋解决的就更好了
后来试了下,好像可以了。 我是看到这个: https://bugs.pypy.org/issue569 以为与64位有关xi的……
跟64位xi统没关xi,楼住看下python是什么版本的?
和64没关xi啊 我64一直正常