大网数据广告活动
服务器运维问答

Unable to run Expect " no more ptys. " as normal user

· 52CE 我爱测

I have an LXC container with CentOS 7.4 running. On running expect from Normal user I am getting the below error. user@server ~> expect -c "spawn ls" spawn ls The system has no more ptys. Ask your system administrator to create m…

问题原文

原帖链接 · nirmalraj17 · CC BY-SA 3.0

I have an LXC container with CentOS 7.4 running.
On running expect from Normal user I am getting the below error.

user@server ~>  expect -c "spawn ls"
spawn ls
The system has no more ptys.  Ask your system administrator to create more.
    while executing
"spawn ls"


But if we execute the same from root user, It works.

[root@server]#  expect -c "spawn ls"
spawn ls

The output of mount also have these in mount point. devpts on /dev/pts type devpts (rw,relatime,seclabel,mode=620,ptmxmode=000)

I have ran the below updates in the server.

mknod -m 600 /dev/console c 5 1 2>/dev/null
mknod -m 666 /dev/null c 1 3 2>/dev/null
mount -n -t tmpfs none /dev 2>/dev/null
mknod -m 622 /dev/console c 5 1 2>/dev/null
mknod -m 666 /dev/null c 1 3 2>/dev/null
mknod -m 666 /dev/zero c 1 5 2>/dev/null
mknod -m 666 /dev/ptmx c 5 2 2>/dev/null
mknod -m 666 /dev/tty c 5 0 2>/dev/null
mknod -m 444 /dev/random c 1 8 2>/dev/null
mknod -m 444 /dev/urandom c 1 9 2>/dev/null
chown root:tty /dev/{console,ptmx,tty} 2>/dev/null
ln -s /proc/self/fd /dev/fd 2>/dev/null
ln -s /proc/self/fd/0 /dev/stdin 2>/dev/null
ln -s /proc/self/fd/1 /dev/stdout 2>/dev/null
ln -s /proc/self/fd/2 /dev/stderr 2>/dev/null
ln -s /proc/kcore /dev/core 2>/dev/null
mkdir /dev/pts 2>/dev/null
mkdir /dev/shm 2>/dev/null
mount -t devpts -o gid=4,mode=620 none /dev/pts 2>/dev/null
mount -t tmpfs none /dev/shm 2>/dev/null
chmod 666 /dev/null

But still I am not able to run the expect command as a normal user.
I have some scripts which needs to be run as normal user with expect statements.

I have done all possible ways which I can think of. Please help!!

已采纳解答

原帖链接 · nirmalraj17 · CC BY-SA 3.0

After quite a bit of searching, I found that I needed to create the /dev/ptmx and /dev/pts structures inside the chroot.

 #!/bin/sh
 mknod /dev/ptmx c 5 2
 chmod 666 /dev/ptmx
 mkdir /dev/pts
 chmod 755 /dev/pts
 mount -t devpts -o gid=5,mode=620 none /dev/pts

Thanks to the website https://mintcast.org/building-linux/ I have quoted the script and the details from the above site.

After executing the script, I was able to execute the command

[user@server]#  expect -c "spawn ls"
spawn ls

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-01-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。