Difficulties running commands in shells from Perl
Hello :)
I'm getting something(s) wrong, trying to run commands (both simple and piped) in shells from Perl programs. The ultimate objective is to set up "copy X selection to clipboard" from urxvt but apparently simple debugging statements are not working. Here's the Perl, taken from here and modified to use xclip instead of xsel and with debugging added, shown in green Code:
#! /usr/bin/perl The xclip command is OK as shown by running Code:
echo foo | /usr/bin/xclip -in -selection clipboard Perhaps there is something wrong with the open() call. Not knowing how to investigate further I switched to the other sample Perl script, here shown with added debug statements Code:
#! /usr/bin/perl What is wrong with the two system() calls that are intended to create /tmp/on_sel_grab.2.log? Best Charles |
Quote:
So, how is it supposed to work ? |
Thanks for replying Sergei :)
The file is in the urxvt terminal emulator's default Perl library directory /usr/lib/urxvt/perl. It is called "clipboard" and is named in ~/.Xresources in the line URxvt.perl-ext-common: default,matcher,clipboard clipboard's on_sel_grab() function is called when text is selected in the urxvt terminal emulator. After that my understanding is weak. Paraphrasing the urxvtperl man page ... urxvt has a built in Perl interpreter. When a terminal is created the urxvt Perl extensions named as above or on the command line are loaded. |
Quote:
Now regarding the piece of code: Code:
open (my $pipe,'|-','/usr/bin/xclip -in -selection clipboard') or die; Code:
open (my $pipe,'| /usr/bin/xclip -in -selection clipboard') or die; If it doesn't work, I'd suggest to temporarily replace '/usr/bin/xclip -in -selection clipboard' with a script/program which, say, echoes its STDIN to STDERR - for diagnostic purposes, to make sure that $pipe indeed gets data and passes it to the forked process. |
Quote:
Code:
#! perl Quote:
|
Quote:
|
All times are GMT -5. The time now is 03:59 AM. |