Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 161770

Summary: IShellService.runCommand fails with SSH
Product: [Tools] Target Management Reporter: Lothar Werzinger <lothar>
Component: RSEAssignee: Martin Oberhuber <mober.at+eclipse>
Status: RESOLVED FIXED QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: 1.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
test case
none
helper class needed by previous attachment none

Description Lothar Werzinger CLA 2006-10-20 15:02:30 EDT
IShellService.runCommand works not with every Shell. It fails with SSH.
I tested with RSE 1.0RC1.
I found that testing several connections for Bug 158786. 
( https://bugs.eclipse.org/bugs/show_bug.cgi?id=158786#c10 )

I don't know if this problem affects different Platform/OS, so I picked "All". Feel free to change that if necessary.
Comment 1 Martin Oberhuber CLA 2006-10-20 16:59:36 EDT
Can you provide some sample test code that exercises IShellService.runCommand -- a bit simpler than your code in bug 158786#c6 ?

It might help to look at 
org.eclipse.rse.examples.tutorial/samples.ui.actions/ShowJarContents.java
which works fine through ssh too 
(with examples installed, use UI action "Show Contents" on a jarfile)
Comment 2 Lothar Werzinger CLA 2006-10-20 17:58:45 EDT
Created attachment 52437 [details]
test case

Copy the attached java file into the example plugin and add the following action to the plugin.xml

	<extension point="org.eclipse.rse.ui.popupMenus">
		<objectContribution id="actions.jar"
							typecategoryfilter="files"
							typefilter="file"
							namefilter="*.jar">
			<action id="actions.jar.show"
					enablesFor="1"
					label="Show contents (2)"
					tooltip="List contents of this file"
					class="samples.ui.actions.CopyOfShowJarContents">
			</action>
		</objectContribution>
	</extension>

depending on how you compile the java file (set the if to true or false) you get:

output with runCommand ...
Last login: Fri Oct 20 14:56:35 2006 from 172.16.92.1
lothar@janus:~$ 

output with launchShell+writeToShell ...
Last login: Fri Oct 20 14:58:32 2006 from 172.16.92.1
lothar@janus:~$ jar -tvf /home/lothar/workspace/tradescapeAPI/lib/java-stubs.jar lothar@janus:~$ jar -tvf /home/lothar/workspace/tradescapeAPI/lib/java-stubs.jar
     0 Thu Oct 12 00:11:20 PDT 2006 META-INF/
   106 Thu Oct 12 00:11:18 PDT 2006 META-INF/MANIFEST.MF
...
lothar@janus:~$
Comment 3 Lothar Werzinger CLA 2006-10-20 18:01:29 EDT
Created attachment 52438 [details]
helper class needed by previous attachment

copy this helper class into the same directory as attachment https://bugs.eclipse.org/bugs/attachment.cgi?id=52437
Comment 4 Martin Oberhuber CLA 2006-10-20 19:16:27 EDT
Ah, I see. Its marked as TODO in SshShellService.runCommand().
Should be easy to fix - surprising that it works ok with dstore.

Decreasing severity to NORMAL since there is a workaround (use launchShell() + writeToShell())
Comment 5 Martin Oberhuber CLA 2006-11-02 08:01:42 EST
Fix ssh remote cmd invocation and environment variable setup according to API:
SshHostShell, SshShellService
Comment 6 Martin Oberhuber CLA 2008-08-13 13:08:13 EDT
[target cleanup] 1.0 RC3 was the original target milestone for this bug