Bug 212742 - [api] Need a Utility to send commands and receive output without prompt
Summary: [api] Need a Utility to send commands and receive output without prompt
Status: NEW
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: Future   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL: http://dev.eclipse.org/newslists/news...
Whiteboard:
Keywords: api, plan
Depends on:
Blocks:
 
Reported: 2007-12-12 09:00 EST by Martin Oberhuber CLA
Modified: 2012-05-22 14:58 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2007-12-12 09:00:18 EST
From http://dev.eclipse.org/newslists/news.eclipse.dsdp.tm/msg00269.html :

I would like to use RSE API to execute remote commands and get their result strings. However, as far as I tried, I cannot find any way to get only the result of the commands, that is, not including remote host's login greeting message nor shell prompt.

In the EclipseCon "nm" example, we used SimpleCommandOperation to return results of a remote "nm" command. However, it looks like only dstore is capable of returning results without the remote prompt. Other shells like SSH return the remote prompt intermixed with the results.

I find it unfortunate that the SimpleCommandOperation works differently on different kinds of subsystem. We should have one API (or coding example) that works the same on all kinds of subsystem.

I'm not sure whether it would be better to add API to IHostShell and related interfaces such that they need to provide a method for running commands without a prompt intermixed; or, whether it is better to provide one common utility class, based on RemoteCommandOperation, that uses pattern matching to filter out the remote prompt. Both have their pros and cons.

One suggestion for a solution was made in 
   http://dev.eclipse.org/newslists/news.eclipse.dsdp.tm/msg00281.html
but it would be better to have simpler API (or an official example) for this.

Let's discuss here what's the best approach for making such API happen.
Comment 1 Martin Oberhuber CLA 2007-12-12 09:32:03 EST
This issue is probably related to improper prompt handling in shells in general:
See also bug 162857, bug 149285, bug 164101.

One problem of a generic solution (in RemoteCommandShellOperation) is that it doesn't easily know what the command separator or "echo" command on a remote system is supposed to be, or whether it's even possible to join multiple commands on a single command-line with a separator.

One problem of an API with specific implementations in the shell service is that a service like SSH also doesn't know the kind of remote shell exactly, and thus a lot of code which would really belong in a higher level needs to be duplicated in multiple services. I'd rather keep the shell service really simple.

Personally, I'm slightly in favor of a high-level solution based on RemoteCommandShellOperation, since this is the only possible solution that also supports multiplexing of multiple commands, or deferred operation if an existing command is still running, even if the kind of remote shell is really limited (like Telnet). 

The open question is, what to do if a remote system does not support an "echo" command or a command separator. Perhaps it could filter out the prompt based on pattern matching? The dstore command miner also does this, any line that ends with a ">" character is considered a prompt and potentially filtered out.
Comment 2 Martin Oberhuber CLA 2007-12-12 09:54:48 EST
The code in
  http://dev.eclipse.org/newslists/news.eclipse.dsdp.tm/msg00281.html
actually works fine on dstore and ssh, but relies on the fact that the remote side echos commands: because the BEGIN-END-TAG from the original command echo is taken as the begin tag.
 
Can we take it for granted, that
(a) commands are always echoed by the remote, and
(b) the command echo is not interleaved with output from a previous 
    still running command?
Comment 3 Martin Oberhuber CLA 2008-02-20 17:41:09 EST
Bulk reassign missed M5 tasks to M6
Comment 4 David McKnight CLA 2008-04-02 17:01:10 EDT
Moving this to future as it's API and for now we can try to use RemoteCommandShellOperation.
Comment 5 Martin Oberhuber CLA 2008-04-02 18:08:59 EDT
Actually, if we go the route of changing implementation of SSH (and Telnet) IHostShell, such that they are in sync with what DStore does, it's not an API change... I'm not giving up yet.
Comment 6 Martin Oberhuber CLA 2008-05-07 05:13:37 EDT
Not for M7
Comment 7 Martin Oberhuber CLA 2008-05-20 18:19:13 EDT
Bulk update of target milestone
Comment 8 Martin Oberhuber CLA 2008-07-10 12:20:04 EDT
This is one of the most frequently requested enhancements by adopters.
I think we'll have to do this in 3.1 if we want to further grow the Community.

Also, having a proper Utility class for this might simplify User Actions.
Comment 9 Martin Oberhuber CLA 2011-05-31 17:41:50 EDT
Moving deferred 3.3 api items to 3.4
Comment 10 Martin Oberhuber CLA 2012-05-22 14:58:35 EDT
We are post API freeze.