Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tm-dev] code snippet to open remote terminal programmatically in eclipse terminals view and execute shell commands programmatically in it

Hello Greg,

Thanks for your reply. I am using the below code to open a remote shell in Remote shell view and can able to execute commands in it and can able to read the outputs of the commands.

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        IStructuredSelection sel = (IStructuredSelection)window.getSelectionService().getSelection();
        RemoteProcessImpl ele = (RemoteProcessImpl)sel.getFirstElement();
        IHost conn = ele.getSystemConnection();
        IRemoteCmdSubSystem cmdSS = RemoteCommandHelpers.getCmdSubSystem(conn);
        Object[] obs = null;
        RemoteOutput fe = null;
        try {
            cmdSS.checkIsConnected(null);
        } catch (SystemMessageException e2) {
            e2.printStackTrace();
        }
        try {
            cmdSS.initializeSubSystem(null);
        } catch (SystemMessageException e1) {
            e1.printStackTrace();
        }
        RemoteCommandShell shell = null;
        try {
            shell = (RemoteCommandShell)cmdSS.getDefaultShell();
        } catch (Exception e) {
            e.printStackTrace();
        }
        shell.removeOutput();
        cmdSS.sendCommandToShell("ls -l", shell, null);
        Thread.sleep(1000);
        obs = new Object[shell.getRoots().length];
        obs = shell.getRoots();
        for (int i = 0; i < obs.length; i++) {
            fe = (RemoteOutput)obs[i];
            String op1 = fe.getText();
            System.out.println(op1);
        }
        command.setLength(0);

I want to do the EXACTLY the same thing for remote terminal i.e want to open a remote terminal in Terminals view[Programmatically] and 
execute commands in it[Programmatically] and read the output of the commands executed in the opened terminal.

Regards,
Chandrayya


On Fri, Aug 12, 2016 at 6:29 PM, Greg Watson <g.watson@xxxxxxxxxxxx> wrote:
I’m not sure exactly what you’re trying to do. Do you want the results of the command you execute to be displayed in the terminal, or do you just want to execute commands programmatically?

The org.eclipse.remote package is tailored to programatic use. It provides a console, works with TM terminal, supports direct command execution and remote shell access, and provides a remote file manipulation interface. You might want to take a look.

Regards,
Greg

On Aug 12, 2016, at 3:27 AM, chandrayya kumarswamimath <chandrayya.gk@xxxxxxxxx> wrote:

Hello All,

I need an example code snippet to open remote terminal programmatically in eclipse terminals view and execute shell commands programmatically in it.

I posted the same question here http://stackoverflow.com/q/38871861/1391924 and here https://www.eclipse.org/forums/index.php?t=msg&th=1079876&goto=1739730&#msg_1739730 but not got any answers.

Also similar message is posted here https://dev.eclipse.org/mhonarc/lists/tm-dev/msg01128.html but in code it is not mentioned how to execute commands and terminal is not opening.

Please help me in this regard.


--
Regards,
Chandrayya.G.K


_______________________________________________
tm-dev mailing list
tm-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tm-dev


_______________________________________________
tm-dev mailing list
tm-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tm-dev



--
Regards,
Chandrayya.G.K



Back to the top