Spawning TTYs

less than 1 minute read

The following commands should be executed from the Linux command line. What TTY you’re able to spawn will come down to available shells on the host - cat /etc/shells

Python

python -c 'import pty; pty.spawn("/bin/bash")'
python -c 'import pty; pty.spawn("/bin/sh")'

echo os.system('/bin/bash')
echo os.system('/bin/sh')


Interactive shells

/bin/bash -i
/bin/sh -i


Perl

perl  -e 'exec "/bin/bash";'
perl  -e 'exec "/bin/sh";'


Ruby

exec "/bin/bash"
exec "/bin/sh"


Lua

os.execute('/bin/bash')
os.execute('/bin/sh')


Vim

// From within vim
:!bash
:set shell=/bin/bash:shell