Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Tk Listbox and SSH command

by Praetrorian (Novice)
on Jan 16, 2023 at 10:03 UTC ( [id://11149608]=perlquestion: print w/replies, xml ) Need Help??

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

Hello there, I've been using Perl for few years now and I'm lurking here since then. I've always been able to solve my issues with previous posts. But I just encountered a problem that I don't even know how I should formulate it in the search bar... Some context : I do some VHDL simulation on a distant server using SSH. Those simulations create .vcd files that can be viewed with a software called GTKWave through a X11 server. My job right now, is to develop a simple user interface to do this without the user to have to do command line stuff. I'm using Net::SSH::Perl (Net::OpenSSH not working on Windows) and Tk. The SSH command I send to view the .vcd file is :

DISPLAY=192.my_local_ip:42.0 gtkwave waveform.vcd

This command works perfectly in my Perl script (I've removed some code for clarification):

my @selected_waves = $waves_listbox->curselection(); my $wave = $waves_listbox->get($selected_waves[0]); # $wave = "waveform.vcd"; my ($stdout, $stderr, $exit); my $gtk_cmd = "$disp_pref gtkwave $simu_folder/$wave"; print "$gtk_cmd\n"; ($stdout, $stderr, $exit) = $ssh->cmd($gtk_cmd);

So my problem is when $wave is forced to the value "waveform.vcd" it works well. But when I use the listbox selection nothing happens (no error), GTKWave doesn't show up. I print the command I sent and it is exactly the same (there is no \n hiding in the listbox item, i tried to chomp it). I guess the variable $wave behaves differently with the listbox->get, but I don't understand why. I'm curious what you guys think of it. Thank you

Replies are listed 'Best First'.
Re: Tk Listbox and SSH command
by rizzo (Curate) on Jan 16, 2023 at 11:40 UTC

    If you have access to the logs/error logs/journal on the remote host, I'd start out looking there.

      Hello, I asked a colleague who has access. Turns out the command create a fatal error : "message authentication code incorrect". I suspected an encoding problem. So I forced the utf-8 encoding of the variable.

      $gtk_cmd = Encode::encode('UTF-8', $gtk_cmd, Encode::FB_CROAK);

      And it worked perfectly... Thank you for your answer, it led me to the solution. :)

        Glad to hear that.

Re: Tk Listbox and SSH command
by cavac (Parson) on Jan 17, 2023 at 15:12 UTC

    A little off-topic, but thinking about the possible future of your project: If X11-over-Network turns out to be too slow, you could experiment with starting a virtual X11 with a VNC server, then open a VNC client on the user terminal (you can possibly pipe that all back to the client using the existing SSH session via port forwarding to even make it secure).

    Using VNC (or something similar) can be orders of magnitude faster, depending on the use case. VNC sends you a compressed screen update for the parts ofd the screen that have changed (depending on the selected VNC algorithm). On the other hand, worst case case for X11 is that it sends you pixel-by-pixel drawing operations.

    As an additional bonus, if you ever need to generate screenshots of all .vcd files, you could just call Net::VNC instead of the external VNC viewer to automatically capture a screenshot of the application.

    Also, if you ever want to port your project over to a browser, you could use noVNC to just view that application from within a webpage. In theory then, the operating system of the user wouldn't matter at all anymore, because ALL the software runs on the central server and all the client needs is a web browser that supports websockets. (So, basically, every browser made after about 2015...).

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11149608]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-25 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found