Skip to main content


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 16:15 Go to next message
Dmitry Dmitry is currently offline Dmitry DmitryFriend
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 17:32 Go to previous message
Martin Tauber is currently offline Martin TauberFriend
Messages: 122
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: Sat Apr 27 01:50:45 GMT 2024

Powered by FUDForum. Page generated in 0.04038 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top