Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Target Management » Using RSE for creating own builder(Can anyone help in developing code that creates a connection and executes a command?)
Using RSE for creating own builder [message #1159553] Mon, 28 October 2013 12:15 Go to next message
Dmitry Dmitry is currently offline Dmitry Dmitry
Messages: 2
Registered: November 2012
Junior Member
Hi everyone!
I'm currently developing an eclipse plug-in that enables a one-click setup and further remote building of my project.
At the project nature configuration time, I request a user to enter server name, server username and password. I can be sure that connection is an SSH one.
Can anyone please help me in understanding the steps to connect to a server, cd to a src location (predefined) and execute a "make" command with predefined parameters (plus - capture the output)?
As far as I understood by now:
Step 1. SshShellSubSystemConfiguration config = new SshShellSubSystemConfiguration();
???
Step N. IServiceCommandShell shell = config.createRemoteCommandShell(null, null);
shell.getCommandSubSystem().runCommand("cd /home/proj/src && make clean all install && cd /home/proj/bin && ./startup_proj.sh", ???, ???);

What are the steps 2-(N-1)?
Is it basically possible to do that with RSE? It is preferrable that any system is not explicitly created in RSE UI.
Thanks in advance?
Re: Using RSE for creating own builder [message #1164437 is a reply to message #1159553] Thu, 31 October 2013 13:32 Go to previous message
Martin Tauber is currently offline Martin Tauber
Messages: 116
Registered: July 2009
Senior Member
Am 28.10.13 17:15, schrieb Dmitry Dmitry:
> Hi everyone!
> I'm currently developing an eclipse plug-in that enables a one-click
> setup and further remote building of my project.
> At the project nature configuration time, I request a user to enter
> server name, server username and password. I can be sure that connection
> is an SSH one.
> Can anyone please help me in understanding the steps to connect to a
> server, cd to a src location (predefined) and execute a "make" command
> with predefined parameters (plus - capture the output)?
> As far as I understood by now:
> Step 1. SshShellSubSystemConfiguration config = new
> SshShellSubSystemConfiguration();
> ???
> Step N. IServiceCommandShell shell =
> config.createRemoteCommandShell(null, null);
> shell.getCommandSubSystem().runCommand("cd /home/proj/src &&
> make clean all install && cd /home/proj/bin && ./startup_proj.sh", ???,
> ???);
>
> What are the steps 2-(N-1)?
> Is it basically possible to do that with RSE? It is preferrable that any
> system is not explicitly created in RSE UI.
> Thanks in advance?

Hi Dimitry,

you can create a connection to the remote system like this:


IHost host = registry.getHost(profile, hostFieldValue);
if (host == null) {
try {
host =
registry.createHost(RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID),
hostFieldValue, hostFieldValue, "Connection to
" + hostFieldValue);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


or use the gui elements from rse liek the remote explorer

then you can run a commamd on the remote host


IRemoteCmdSubSystem cmdSS = this.getCmdSubSystem();
SimpleCommandOperation op = new SimpleCommandOperation(cmdSS,
workingDir, true);

try {
op.runCommand(command, true);
} catch (Exception e) {
e.printStackTrace();
}

String line = op.readLine(true);
while (line != null) {
this.WriteToConsole(line);
lines.add(line);
line = op.readLine(true);
}


private IRemoteCmdSubSystem getCmdSubSystem() {
ISubSystem[] subSystems;
IHost host = this.getHost();

subSystems = host.getSubSystems();
for (int i=0; i<subSystems.length;i++) {
if (subSystems[i] instanceof IRemoteCmdSubSystem) {
return (IRemoteCmdSubSystem)subSystems[i];
}
}

return null;
}

Regards
Martin
Previous Topic:capture output of one command
Next Topic:Where are the connections stored?
Goto Forum:
  


Current Time: Tue Jul 22 17:42:50 EDT 2014

Powered by FUDForum. Page generated in 0.01397 seconds