Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 52437 Details for
Bug 161770
IShellService.runCommand fails with SSH
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
test case
CopyOfShowJarContents.java (text/plain), 4.43 KB, created by
Lothar Werzinger
on 2006-10-20 17:58:45 EDT
(
hide
)
Description:
test case
Filename:
MIME Type:
Creator:
Lothar Werzinger
Created:
2006-10-20 17:58:45 EDT
Size:
4.43 KB
patch
obsolete
>/******************************************************************************** > * Copyright (c) 2006 IBM Corporation. All rights reserved. > * This program and the accompanying materials are made available under the terms > * of the Eclipse Public License v1.0 which accompanies this distribution, and is > * available at http://www.eclipse.org/legal/epl-v10.html > * > * Initial Contributors: > * The following IBM employees contributed to the Remote System Explorer > * component that contains this file: David McKnight, Kushal Munir, > * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, > * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. > * > * Contributors: > * Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE. > ********************************************************************************/ > >package samples.ui.actions; > >import org.eclipse.core.runtime.CoreException; >import org.eclipse.core.runtime.IStatus; >import org.eclipse.core.runtime.NullProgressMonitor; >import org.eclipse.core.runtime.Status; >import org.eclipse.jface.dialogs.MessageDialog; >import org.eclipse.rse.core.model.IHost; >import org.eclipse.rse.core.subsystems.ISubSystem; >import org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction; >import org.eclipse.rse.services.IService; >import org.eclipse.rse.services.shells.IHostShell; >import org.eclipse.rse.services.shells.IShellService; >import org.eclipse.rse.shells.ui.RemoteCommandHelpers; >import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; >import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; >import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem; >import org.eclipse.swt.widgets.Display; > > >/** > * An action that runs a command to display the contents of a Jar file. > * The plugin.xml file restricts this action so it only appears for .jar files. > */ >public class CopyOfShowJarContents extends SystemAbstractRemoteFilePopupMenuExtensionAction { > > /** > * Constructor for ShowJarContents. > */ > public CopyOfShowJarContents() { > super(); > } > > /* (non-Javadoc) > * @see org.eclipse.rse.ui.actions.SystemAbstractPopupMenuExtensionAction#run() > */ > public void run() { > IRemoteFile selectedFile = getFirstSelectedRemoteFile(); > String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath(); //$NON-NLS-1$ > try { > runCommand(cmdToRun); > } catch(Exception e) { > MessageDialog.openError(getShell(), e.getClass().getName(), e.getLocalizedMessage()); > } > } > > public IRemoteCmdSubSystem getRemoteCmdSubSystem() { > //get the Command subsystem associated with the current host > IHost myHost = getSubSystem().getHost(); > IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost); > for (int i=0; i<subsys.length; i++) { > if (subsys[i].getSubSystemConfiguration().supportsCommands()) { > return subsys[i]; > } > } > return null; > } > > protected IService getShellService( ) throws CoreException > { > IHost myHost = getSubSystem().getHost(); > > ISubSystem[] subSystems = myHost.getSubSystems(); > int i = 0; > for (i = 0; i < subSystems.length; i++) > { > if (subSystems[i] instanceof IShellServiceSubSystem) > break; > } > if (i >= subSystems.length) > return null; > > final ISubSystem subsystem = subSystems[i]; > > Display.getDefault().syncExec(new Runnable() > { > public void run() > { > try > { > subsystem.connect(false); > } > catch (Exception e) > { > // Ignore > } > } > }); > > if (!subsystem.isConnected()) > { > MessageDialog.openError(getShell(), "Could not connect", "Could not connect to subsystem"); > } > > return ((IShellServiceSubSystem) subsystem).getShellService(); > } > > public void runCommand(String command) throws Exception > { > IShellService shellService = (IShellService) getShellService(); > > if(true) > { > System.out.println("output with runCommand ..."); > IHostShell hostShell = shellService.runCommand(new NullProgressMonitor(), ".", command, null); > HostShellAdapter remoteProcess = new HostShellAdapter(hostShell); > } > else > { > System.out.println("output with launchShell+writeToShell ..."); > IHostShell hostShell = shellService.launchShell(new NullProgressMonitor(), ".", null); > hostShell.writeToShell(command); > HostShellAdapter remoteProcess = new HostShellAdapter(hostShell); > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 161770
: 52437 |
52438