AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1091553
Accepted
Stuperfied
Stuperfied
Asked: 2018-11-10 16:17:08 +0800 CST2018-11-10 16:17:08 +0800 CST 2018-11-10 16:17:08 +0800 CST

如何修复“错误打开终端:未知”。在 Ubuntu 服务器上?

  • 772

我搜索并发现了类似的问题,但没有一个足够具体或解决我的问题。一个例子是这个问题通过 ssh 启动基于远程脚本/终端的程序会给出错误(打开终端时出错:未知。)我没有使用ssh,所以-t没有帮助。


运行 webmin,已经好几个月了,现在我得到了这个错误。

基本上,当我在终端中输入 nano 或 vi 时,我收到错误“打开终端时出错:未知”。

[user@host ~]# nano
Error opening terminal: unknown.
[user@host ~]# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
[user@host ~]# nano
Error opening terminal: unknown.

[user@host ~]# 

如何修复“错误打开终端:未知”。在运行 webmin 的 Ubuntu 16.04.3 LTS 上?

新的信息:

  1. 当我尝试直接在服务器上运行 vi 或 nano 而不是使用 webmin 或 ssh 进行远程访问时,它可以工作。这可能只是 webmin 的问题吗?
  2. 当我检查环境变量时,它说TERM=linux这与我运行所有相同软件的其他服务器一致。
server command-line webmin
  • 4 4 个回答
  • 32440 Views

4 个回答

  • Voted
  1. LeonidMew
    2018-11-10T16:24:03+08:002018-11-10T16:24:03+08:00

    尝试运行/bin/bash,我认为它会分配伪tty

    也试试: TERM=linux 然后运行 ​​nano

    • 6
  2. Best Answer
    Ilia
    2018-11-14T03:21:13+08:002018-11-14T03:21:13+08:00

    Webmin 终端尚未交互。事实上,它是一个命令行界面。

    你可以阅读更多关于它的信息,我们讨论了很多。

    我们的任务是让它具有交互性。

    • 2
  3. SurpriseDog
    2019-05-02T16:15:06+08:002019-05-02T16:15:06+08:00

    我在尝试编辑 initramfs 中的文件时遇到了这个问题。这是我发现的唯一线程,因此我没有寻找另一个修复程序,而是编写了一个 python 脚本来制作一个在 initramfs(和其他功能较差的终端)内工作的简单文本编辑器

    很简单,一次只显示一行,所以你按上下键换行,左右移动光标,回车保存。没什么花哨的,但它似乎可以快速编辑。

    它只需要 readchar 模块:python3 -m pip install readchar

    #!/usr/bin/python3
    #Edit a text file inside the initramfs (when other text editors don't work)
    '''Compile with: 
    libgcc=$(find /lib -name libgcc_s.so.1 | head -n 1)
    libutil=$(ldd /usr/bin/python3 | grep libutil | cut -d ' ' -f 3)
    pyinstaller --onefile editfile.py  --add-data="$libgcc:." --add-data="$libutil:." --hidden-import readchar
    '''
    import shutil, sys, readchar
    
    
    '''
    Allow user to edit a line of text complete with support for line wraps and a cursor | you can move back and forth with the arrow keys.
    lines = initial text supplied to edit
    prompt= Decoration presented before the text (not editable and not returned)
    '''
    def text_editor(lines=[], prompt=''):
    
        term_width = shutil.get_terminal_size()[0] - 1
        line_num = 0
        if type(lines) in (list, tuple):
            multiline=True
        else:
            multiline=False
            lines=[lines]
    
    
        text = list(lines[line_num])
        ptr = len(text)
        prompt = list(prompt)
        space = [' ']
    
        c = 0
        while True:
            if ptr and ptr > len(text):
                ptr = len(text)
    
    
            copy = text.copy()
            if ptr < len(text):
                copy.insert(ptr,'|')
            copy = list(str(line_num)) + space + prompt + copy
    
            #Line wraps support:
            if len(copy) > term_width:
                cut = len(copy) + 3 - term_width
                if ptr > len(copy) / 2:
                    copy = ['<']*3 + copy[cut:]
                else:
                    copy = copy[:-cut] + ['>']*3 
    
            print('\r'*term_width+''.join(copy), end=' '*(term_width-len(copy)), flush=True)
    
            if c in (53,54):
                #Page up/down bug
                c = readchar.readkey()
                if c == '~':
                    continue
            else:
                c = readchar.readkey()  
    
    
            if len(c) > 1:
                #Control Character
                c = ord(c[-1])
    
                #Save current line on line change
                if c in (53, 54, 65, 66):
                    lines[line_num] = ''.join(text)
    
                if c == 65:     #Up
                    line_num -= 1
                elif c == 66:   #Down
                    line_num += 1
                elif c == 68:   #Left
                    ptr -= 1
                elif c == 67:   #Right
                    ptr += 1
                elif c == 54:   #PgDn
                    line_num += 10
                elif c == 53:   #PgUp
                    line_num -= 10
                elif c == 70:   #End
                    ptr = len(text)
                elif c == 72:   #Home
                    ptr = 0
                else:
                    print("\nUnknown control character:", c)
                    print("Press ctrl-c to quit.")
                    continue
                if ptr < 0:
                    ptr = 0
                if ptr > len(text):
                    ptr = len(text)
    
                #Check if line changed
                if c in (53, 54, 65, 66):
                    if multiline == False:
                        line_num = 0
                        continue
                    if line_num < 0:
                        line_num = 0
                    while line_num > len(lines) - 1:
                        lines.append('')
                    text = list(lines[line_num])
    
    
            else:
    
                num = ord(c)
                if num in (13, 10): #Enter
                    print()
                    lines[line_num] = ''.join(text)
                    if multiline:
                        return lines
                    else:
                        return lines[0]
                elif num == 127:        #Backspace
                    if text:
                        text.pop(ptr-1)
                        ptr -=1
                elif num == 3:          #Ctrl-C 
                    sys.exit(1)
                else:
                    text.insert(ptr, c)
                    ptr += 1
    
    #Main
    if len(sys.argv) == 1:
        print("Usage: ./editfile <filename>")
        sys.exit(1)
    
    f = open(sys.argv[1], 'r')
    strings = f.read().split('\n')
    f.close()
    strings = text_editor(strings)
    
    #Trim empty lines on end
    for x in range(len(strings) -1,0, -1):
        if len(strings[x]):
            break
        else:
            strings.pop(-1)     
    
    
    f = open(sys.argv[1], 'w')
    f.write('\n'.join(strings)+'\n')
    
    • 2
  4. SamiraMiss
    2019-11-15T02:49:45+08:002019-11-15T02:49:45+08:00

    我有同样的问题,并通过以下方式解决:

    sudo apt-get install rxvt-unicode
    
    • 1

相关问题

  • 文件权限如何工作?文件权限用户和组

  • 如何在 Vim 中启用全彩支持?

  • 如果在服务器机器上运行 Ubuntu 桌面版,性能损失是多少?

  • 将桌面版剥离为服务器版的最简单方法是什么?

  • 如何与无头服务器进行图形交互?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve