Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Remote execution of bash commands with IRemoteProcessBuilder(How to programmatically execute bash commands on a remote system using RemoteTools)
Remote execution of bash commands with IRemoteProcessBuilder [message #1231468] Tue, 14 January 2014 18:59
Rocky Dunlap is currently offline Rocky DunlapFriend
Messages: 12
Registered: July 2009
Junior Member
I am attempting to execute the following bash command on a remote system programmatically using RemoteTools:

echo "export ESMFMKFILE=/home/sgeadmin/esmf.mk" >> .profile


Here is the relevant code snippit.

IRemoteServices remoteServices = RemoteServices.getRemoteServices("org.eclipse.ptp.remote.RemoteTools", new SubProgressMonitor(monitor,1));

IRemoteConnection remoteConn = ....;  //acquire remote connection

String command = "echo \"export ESMFMKFILE=/home/sgeadmin/esmf.mk\" >> .profile";
IRemoteProcessBuilder rpb = remoteServices.getProcessBuilder(remoteConn, command);
IRemoteProcess rp = rpb.start();
    
while (!rp.isCompleted()) {
   rp.waitFor();
}

// print stdout
System.out.println("\nProcess stdout:");
BufferedReader in = new BufferedReader(new InputStreamReader(rp.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
in.close();

//print stderr
System.out.println("\nProcess stderr:");
in = new BufferedReader(new InputStreamReader(rp.getErrorStream()));
while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
in.close();


The stderr output of sending the above command is:

Process stderr:
stdin: is not a tty
/bin/bash: echo "export ESMFMKFILE=/home/sgeadmin/esmf.mk" >> .profile: No such file or directory


Actually, even the simple command "echo hello" returns a similar error. Upon digging into the RemoteConnection object, I find the RemoteScript object and the actual command that is sent. It has undergone some serious character escaping:

echo\ \"export\ ESMFMKFILE\=/home/sgeadmin/esmf.mk\"\ \>\>\ .profile


This escaping is built into RemoteToolsProcessBuilder.

My question is how would I go about executing the above command using the RemoteToolsProcessBuilder?

Previous Topic:CDT not recognizing IN and OUT keywords
Next Topic:How to set GDB breakpoint actions?
Goto Forum:
  


Current Time: Thu Apr 25 08:52:52 GMT 2024

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

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

Back to the top