Commit 02eb2156 authored by Leigh Stoller's avatar Leigh Stoller

OSX support ... on a Mac will look to see if you are running X and pop

up an xterm. If you are not running X, will use a bit of applescript
to fire up a Terminal window.

Note that you need to be running an ssh-agent, started when you log
in. One way to do that is http://www.sshkeychain.org. There are
probably other ways as well, but not sure what they are. For
sshkeychain (which I installed and seems to work okay) here are the
instructions:

    * Copy SSHKeychain (SSHKeychain.app) to your Applications folder.
    * Run SSHKeychain. This should open a dock item and a statusbar item.
    * Click either the Statusbar Item, the Dock Item, or MainMenu and
      open the Preferences.
    * Open the Environment tab.
    * Enable "Manage global environment variables". This will make
      SSHKeychain available for other applications.
    * Open the keys tab and see if any of your keys are missing
        (~/.ssh/id_dsa and ~/.ssh/identity are default).
    * Add SSHKeychain to your Login Items in the System Preferences.
    * Re-login to make the global variables work.
    * Start up SSHKeychain, and you're set.
parent 7ebdbd24
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2003, 2006 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -29,6 +29,11 @@ my $gateway;
my $port = "";
my $login = "";
# Protos
sub DoOSX();
sub StartXterm();
sub StartOSXTerm();
#
# Turn off line buffering on output
#
......@@ -82,11 +87,78 @@ close(CONFIG);
if (!defined($hostname)) {
die("Config file must specify a hostname\n");
}
if ($OSNAME eq "darwin") {
DoOSX();
exit(0);
}
StartXterm();
exit(0);
#
# Start up the xterms.
#
sub StartXterm()
{
if (!defined($gateway)) {
exec "xterm -T $hostname -e ssh $port $login $hostname ".
"\|\| read userinput";
}
else {
exec "xterm -T $hostname -e ssh $login -tt $gateway ".
"ssh -o StrictHostKeyChecking=no $port $hostname ".
"\|\| read userinput";
}
}
#
# Mac OSX support; try to deduce the DISPLAY variable.
#
sub DoOSX()
{
my $display;
for (my $i = 0; $i < 20; $i++) {
if (-e "/tmp/.X${i}-lock") {
$display = ":${i}.0";
last;
}
}
if (!defined($display)) {
StartOSXTerm();
return;
}
$ENV{'DISPLAY'} = $display;
if (!defined($gateway)) {
exec "xterm -T $hostname -e ssh $port $login $hostname \|\| read userinput";
# Tell X to activate.
system("osascript -e 'tell application \"X11\" to activate'");
StartXterm();
}
else {
exec "xterm -T $hostname -e ssh $login -tt $gateway ".
"ssh -o StrictHostKeyChecking=no $port $hostname \|\| read userinput";
#
# This is going to start up Terminal.app ... but it depends on you
# having your SSH agent available. The easies way to do that is to
# go here: http://www.sshkeychain.org ... install this application
# and following the instructions to make sure it is launched when
# you log in.
#
sub StartOSXTerm()
{
my $command;
if (!defined($gateway)) {
$command = "ssh $port $login $hostname";
}
else {
$command = "ssh $login -tt $gateway ".
"ssh -o StrictHostKeyChecking=no $port $hostname";
}
exec "osascript -e 'tell application \"Terminal\" \n".
" activate \n".
" do script with command \"$command ; exit\" \n".
" tell window 1 \n".
" set custom title to \"$hostname\" \n".
" end tell \n".
"end tell'";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment