当需要一个类似 screen/tmux 的解决方案时会发生什么(让进程长时间运行,但nohup
因为可能需要交互而不能) - 但是 screen/tmux 在给定的机器上不可用,并且安装了 screen/compiling这不是解决方案吗?
问:是否有任何“简短的”perl 脚本可以(或不通常)用于实现此目标(在 Linux/AIX/等上)?
只需要这个:
有人有这样的 perl 脚本吗?
Sté*_*las 11
perl
除非IO::Pty
安装了模块,否则可能不是最合适的。
首先,如果给定的东西需要很长时间(gtttlt)可以与管道一起正常工作,那么也许您不需要任何复杂的东西。
mkfifo input
nohup gtttlt <> input > output 2>&1 &
Run Code Online (Sandbox Code Playgroud)
启动gtttlt
(从命名管道输入,输出到常规文件)。然后你附加到它:
tail -f output & cat > input
Run Code Online (Sandbox Code Playgroud)
如果管道不起作用并且您需要一个终端,那么您将想要使用可以启动伪终端的东西,如expect
, zsh
's zpty
, perl
'sIO::Pty
或sshd
:
mkfifo input
nohup ssh -tt localhost gtttlt <> input > output 2>&1
Run Code Online (Sandbox Code Playgroud)
并重视:
stty raw -echo; tail -f output & cat > input
Run Code Online (Sandbox Code Playgroud)
请注意,它不像实现screen
or tmux
。screen
并tmux
实现终端模拟器。重新连接时,您会看到该终端仿真器的屏幕内容。在这里重新附加时,您只能看到最后 10 行输出(尽管您可以通过将-n 123
选项传递给 进行调整tail
)。我们只是将所有数据传递到/从主机终端。
归档时间: |
|
查看次数: |
703 次 |
最近记录: |