Sunday, April 19, 2009

screensh

I finally found out how to get ssh "$HOST" screen to work! The secret is shown by this convenient Python script that launches an SSH session to a remote host and starts screen:

screensh.py

#!/usr/bin/python
from subprocess import Popen
from sys import argv, exit, stderr

if len(argv) >= 2:
options = argv[1:-1]
host = argv[-1]
Popen(['ssh', '-t'] + options + [host, 'screen']).communicate()
else:
print >>stderr, 'Usage: %s [ options ] host' % argv[0]
exit(1)

Python really is a "clean" language.

No comments: