# PTP Remote Terminal

Remote Terminal is a lightweight remote terminal that can be used to provide shell access to remote systems from within Eclipse. It is included with the Parallel Tools Platform (PTP) and uses the same connection information that is used by remote and synchronized projects, including the default Built-in SSH.

The Terminal view should be available near the bottom of the workbench.

If you already have a connection and/or a synchronized project, you can open a Terminal

- to the machine with which the project is synchronized - by right-clicking on the project, then selecting "Show Terminal" from the dropdown menu.
- to the machine with which any connection is established - in the Terminal view, select the Connect button.

If the Terminal view is not visible, you can open it via Window > Show View > Other... and under Terminal, select Terminal.

To open a shell directly from the Terminal view, select the Connect button.

In the next dialog, choose Connection Type: to use e.g. Remote Services, and under Settings, select the connection to use. If you have not already established a connection, select New... and enter hostname, user, password, etc. For more information about creating connections, see Remote Services.

Select OK to open the shell on the selected system.

Shell commands can be entered on the selected system.

## Terminal/Eclipse Interaction

It is possible for the shell and the terminal to interact, allowing the eclipse user to have the best of both the command line and the GUI.

For example, a short command can call up the Eclipse editor from the command line:

Commands are initiated by special strings, sometimes called "escape sequences." These sequences are enumerated below:

1. Open File: The string "~~EPTP:OpenFile~~FileName\n" will cause the file named to be opened inside the Eclipse browser. Note that only full path names will work. If the file is part of a synchronized project, Eclipse will open the file as a local file on the client machine. If it is not, it will open the file with an URL using a "remotetools" protocol.
2. Choose a File: The string "~~EPTP:Choice~~File1~~File2~~..~~FileN\n" will open a dialog box in Eclipse and allow the user to choose one of the selected files for opening.
3. Menu: The string "~~EPTP:Radio~~MenuText1::~Command1~~MenuText2::~Command2.." will create a dialog box with a sequence of radio buttons, labeled "MenuText1", "MenuText2", etc. Choosing a given item and clicking OK will cause the corresponding command to be sent to the shell and executed.

It is convenient to invoke the above escape sequences through the use of scripts. The following script is suggested for opening files on the remote machine. An example follows:

    #!/usr/bin/perl
    use strict;
    use File::Spec;
    my @files = ();
    my $aflag = 0;
    for my $a (@ARGV) {
        if($a eq "-a") {
            $aflag = 1;
        } elsif(-r $a) {
            push @files, File::Spec->rel2abs($a);
        }
    }
    if($#files == 0) {
        print "~~EPTP:OpenFile~~",$files[0],"\n";
    } elsif($aflag) {
        for my $file (@files) {
            print "~~EPTP:OpenFile~~",$file,"\n";
            sleep(1);
        }
    } else {
        print "~~EPTP:Choice~~",join("~~",@files),"\n";
    }

Using this script, it is possible to open any file within the Eclipse editor by typing:

      ptp filename

Note that the file name can be relative or absolute.

## Terminal History

A new view is available called "Terminal History." To open it type Window > Show View > Other..., and under the Other category, select "Terminal History."

If you opened any terminals using "Show Terminal" on any synchronized projects, this view will show you your shell histories on the remote machines. In order for this to work, however, you must add a few special commands to your startup files on the remote machines.

1. For Bash: Add "history -a" to your ~/.bashrc
2. For Tcsh/Csh: Add "set history=100;set savehist=100;alias precmd 'history -S'" to your ~/.cshrc. Feel free to change the number "100" to whatever number of items you wish to retain in your shell history.

As you type each new command, it will appear in the top of the history view, pushing the older commands down.

1. If you wish to keep one of the commands near the top of the view, click the checkbox.
<.i>If you wish to re-execute the command from the history, click the numbered button at the left.
2. If you wish to delete the command from the history, click the "X" button on the right.
3. If you wish to edit the command, click inside the text box containing it.

## Other Features

To create an additional view for another terminal connection use New Terminal View from the dropdown menu next to the button in the view toolbar.

Then multiple Terminal views will exist, each with a different connection.

Back to Top | Back to Table of Contents