gold_mark has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I need to run some X programs on remote machine (ssh connection, public key authentication) from my script. It is actually xterm with some data output. I need to have xterm window opened on my local (Linux) machine.
I tried passing -X or -Y ssh options in "new" using default_ssh_opts like this:
my $ssh = Net::OpenSSH->new($host, default_ssh_opts => ['-Y']); my $cmd = 'xterm'; $ssh->system($cmd) or die "Failed to run command: ". $ssh->error;
and also without quotes, but this does not work (the xterm complains DISPLAY is not set).
How could it be done (if at all)?

Replies are listed 'Best First'.
Re: Is it possible to use X forwarding in Net::OpenSSH?
by salva (Canon) on Apr 16, 2013 at 09:07 UTC
    I have just uploaded to CPAN version 0.61_02 with support for X11 forwarding.

    X11 forwarding has to be activated both on the constructor and on the individual commands as follows:

    my $ssh = Net::OpenSSH->new($host, forward_X11 => 1); $ssh->system({forward_X11 => 1}, 'xterm') or die "Failed to run command: ". $ssh->error;
      Thanks a lot. I tried it in simple case and it works.
      Will try full scenario later.
Re: Is it possible to use X forwarding in Net::OpenSSH?
by hdb (Monsignor) on Apr 16, 2013 at 08:26 UTC

    xterm has a -display option.

    xterm -display hostname:0.0