Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dsdp-tm-dev] Questions about runCommand()


Hi Greg,


The IShellService.runCommand(), for most implementations, starts a shell and runs that command in the shell - the shell is probably not exited and that would explain why isActive() returns false.  This should be about the same as doing shellService.runShell(), and then using IHostShell.writeToShell("ls") to run the command.

IShellService shellService = ((IShellServiceSubSystem)  
subSys).getShellService();
IHostShell hostShell = shellService.runShell("", "", new NullProgressMonitor());
hostShell.getStandardOutputReader().addOutputListener(new  
IHostShellOutputListener() {
                public void shellOutputChanged(IHostShellChangeEvent event) {
                                 ...
                }
}

...
hostShell.writeToOutput("ls");

One alternative to this approach would be to use SimpleCommandOperation.  This isn't as efficient as using a listener but it makes it easier to get at simple output.  It provides a more direct API way to get at the output of a shell:

SimpleCommandOperation op =  new SimpleCommandOperation(subSys, workingDirectory, true);
op.runCommand("ls", true);
String line = op.readLine(true);
while (line != null)
{
  ...
  line = op.readLine(true);
}

____________________________________
David McKnight    
Phone:   905-413-3902 , T/L:  969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail:       D1/YFY/8200/TOR
____________________________________



Greg Watson <g.watson@xxxxxxxxxxxx>
Sent by: dsdp-tm-dev-bounces@xxxxxxxxxxx

14/06/2007 06:13 PM

Please respond to
Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>

To
Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>
cc
Subject
[dsdp-tm-dev] Questions about runCommand()





I'm running a command on a remote machine as follows:

IShellService shellService = ((IShellServiceSubSystem)  
subSys).getShellService();
IHostShell hostShell = shellService.runCommand("", "ls", "", new  
NullProgressMonitor());
hostShell.getStandardOutputReader().addOutputListener(new  
IHostShellOutputListener() {
                public void shellOutputChanged(IHostShellChangeEvent event) {
                                 ...
                }
}

Questions:

1. Since it's only possible to add an output listener after the  
runCommand(), is it possible to lose some of the output from the  
command, or is it buffered somewhere?

2. How can I tell when the command is completed? I tried using  
hostShell.isActive(), but it always seems to return true.

Thanks,

Greg
_______________________________________________
dsdp-tm-dev mailing list
dsdp-tm-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dsdp-tm-dev


Back to the top