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?