On 02/09/2012 08:13 PM, Shai Ayal wrote:
On Thu, Feb 9, 2012 at 7:52 PM, Mattia <mat...@tekno-soft.it
<mailto:mat...@tekno-soft.it>> wrote:
Hello list!
I'm facing some troubles trying to execute any kind of graphical
program using JSch (versions 0.1.45 and 0.1.46). I built a sort of
wrapper class over JSch for my project's needs and it works fine
without X11 forwarding (what I need in this case is running and
controlling remote instances of non-graphical applications, using
ChannelExec).
When I try to use my class to write even simple test applications that
use X forwarding though, I encounter some troubles that I haven't been
able yet to solve. The sample test connects to a Ubuntu 10.04 virtual
machine from a Fedora 16 machine (and the other way around) and tries
to run the command /usr/bin/xterm (note: when I run tests from the
Ubuntu VM I am currently logged inside of it using standard OpenSSH
with X forwarding). I haven't noticed any particular difference in
behavior between the two ways. The connect method does nothing fancy
really, it's basically by-the-book setup of session and channelExec
with these lines dedicated to X forwarding:
// Set up for X11 forwarding
session.setX11Host( System.getenv( "HOSTNAME" ) );
session.setX11Port(6000);
// note: these are the defaults, I can and usually do change
// them at runtime passing the equivalent of `hostname` and
// whatever is after the ":" in $DISPLAY + 6000.
[...]
// Allocate a pseudo virtual terminal
channel.setPty( true );
// Set the pty type to "xterm". Default is "vt100"
channel.setPtyType( "xterm" );
channel.setXForwarding( true );
What happens is that the program appears to connect fine, but doesn't
display the xterm window. The sample X11Forwarding that comes with the
library works kinda fine, because I can successfully spawn a new
shell, BUT I can't launch X applications from inside of it because I
incur in the typical "xterm Xt error: Can't open display:
localhost:12.0". If I manually set the $EDITOR env variable from
inside this shell to the same value it has in a "working" shell
(meaning I can start X programs from it), it works as expected
(obviously, I'd say!).
What I thought might be the cause of this behavior (excluding problems
in my code) is the fact that Fedora does not listen to a TCP port for
X but has a socked in /tmp (note problem I guess, I found references
of this before while googling but haven't tried the socat trick
yet) and the
Ubuntu VM has $DISPLAY in the form HOST:n.v (specifically,
ubuntu32:10.0), which afaics is not compatible with JSch (setX11port
accepts ints) and *maybe* I should be specific in saying that I want
to display in that specific virtual display (IIRC "visual display" is
the official name for whatever comes after the dot), and not simply in
the 10th display.
Let me know if more information is necessary!
Mattia
I think the way to open an xterm is not by setting PTY type, but by
actually executing the command
/usr/bin/xterm -display $DISPLAY
What you have is a PTY - more of a text pipe to the remote system
Shai
--
SPT <https://market.android.com/details?id=org.ayal.SPT> - persistent
SSH tunnels for android.
That solves part of the problem indeed - self connection, that is
connecting to the same machine were I'm running the test program from.
It's not really what I need though.
Thanks for the tip for setting the display using the argument, I
expected the program to use whatever it would find in the environment.
I still have trouble making a standard connection though, that is
running the "foreign" application in the machine where I'm running the
test, same problems I was witnessing yesterday.
Thanks for the help!
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users