Have a look at reptyr, which does exactly that. The github page has all the information.
reptyr – A tool for “re-ptying” programs.
reptyr is a utility for taking an
existing running program and attaching
it to a new terminal. Started a
long-running process over ssh, but
have to leave and don’t want to
interrupt it? Just start a screen, use
reptyr to grab it, and then kill the
ssh session and head on home.USAGE
reptyr PID
“reptyr PID” will grab the process
with id PID and attach it to your
current terminal.After attaching, the process will take
input from and write output to the new
terminal, including ^C and ^Z.
(Unfortunately, if you background it,
you will still have to run “bg” or
“fg” in the old terminal. This is
likely impossible to fix in a
reasonable way without patching your
shell.)
Related Posts:
- Kill detached screen session [closed]
- Changing the resolution of a VNC session in linux
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- Terminal Multiplexer for Microsoft Windows – Installers for GNU Screen or tmux
- Can I nohup/screen an already-started process?
- How to reconnect to a disconnected ssh session
- Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]
- How to re-order windows, change the scroll shortcut, and modify the status bar contents in GNU Screen?
- Can I send some text to the STDIN of an active process running in a screen session?
- How do I deal with a filename that starts with the hyphen (-) character?
- Bash: No such file or directory?
- What’s a .sh file?
- How can I symlink a file in Linux? [closed]
- How to fix ‘sudo: no tty present and no askpass program specified’ error?
- How to get the url of the current svn repo?
- How to unmount a busy device
- How to unmount a busy device
- performing HTTP requests with cURL (using PROXY)
- No space left on device
- How to perform grep operation on all files in a directory?
- Amazon Linux: apt-get: command not found
- Pass a password to ssh in pure bash
- How can I exclude directories from grep -R?
- gcc: error: unrecognized command line option
- How to set proxy for wget?
- How to change permissions for a folder and its subfolders/files in one step
- Difference between using “chmod a+x” and “chmod 755”
- ssh: Could not resolve hostname [hostname]: nodename nor servname provided, or not known
- Docker can’t connect to docker daemon
- Need a good hex editor for Linux
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Directory Inode vs Regular File Inode
- How to cat <
> a file containing code? - Diff command along with Grep gives “Binary file (standard input) matches”
- can’t remove python pip
- What does it mean to mount a file system in linux?
- How would I get a cron job to run every 30 minutes?
- How to automatically redirect HTTP to HTTPS on Apache servers?
- Trying to use bash on Windows and got no installed distributions message
- “Unable to find remote helper for ‘https'” during git clone
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- -bash: fork: Cannot allocate memory
- Is there a “goto” statement in bash?
- tar: Cowardly refusing to create an empty archive
- How can I delete a user in linux when the system says its currently used in a process
- Command to change the default home directory of a user
- Post request with Wget?
- Read and write to binary files in C?
- Telnet [Unable to connect to remote host: Connection refused]
- Can’t remove a directory in Unix
- Is there an alternative sleep function in C to milliseconds?
- Gedit command not working in kali linux terminal
- Syntax error near unexpected token ‘then’
- Curl : connection refused
- How to install Android SDK on Ubuntu?
- C fopen vs open
- How can I use grep to show just filenames on Linux?
- Bash script prints “Command Not Found” on empty lines
- httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
- Why does “docker attach” hang?
- Bash export command
- How to edit gitignore file
- Retrieve last 100 lines logs
- What are various options / arguments for “./configure” in Linux
- Adding a new entry to the PATH variable in ZSH
- CronJob not running
- Delete .DS_STORE files in current folder and all subfolders from command line on Mac
- bash sh – command not found
- Hosting multiple WordPress sites on single server – best practices?
- How to configure WP filesystem access in Linux (Ubuntu Server)?
- Can’t upload media to my Raspberry Pi WordPress server
- My WordPress is giving me an 403 error when saving post/draft with specific words
- Anyone else experiencing high rates of Linux server crashes during a leap second day?
- How can I run Debian stable but install some packages from testing?
- Environment variables of a running process on Unix?
- In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain?
- Shell command to monitor changes in a file
- Meaning of the buffers/cache line in the output of free
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- how to disable SSH login with password for some users?
- Difference in sites-available vs sites-enabled vs conf.d directories (Nginx)?
- Disk full, du tells different. How to further investigate?
- Filename length limits on linux?
- best way to clear all iptables rules
- How can I port forward with iptables?
- Why do we use a OS Base Image with Docker if containers have no Guest OS?
- How can I rename a Unix user?
- How to make Windows 7 USB flash install media from Linux?
- How to install/change locale on Debian?
- What limits the maximum number of connections on a Linux server?
- How to prevent a user from login in, but allow “su – user” in Linux?
- I have a keypair. How do I determine the key length?
- How to do the port forwarding from one ip to another ip in same network?
- Why drop caches in Linux?
- Linux – Is there a way to prevent/protect a file from being deleted even by root?
- swap partition vs file for performance?
- Best way to disable swap in Linux
- How to remove invalid characters from filenames?
- How can I zip/compress a symlink?
- How to find the physical volume(s) that hold a logical volume in LVM