Re: I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

On 03/06/2017 12:20 AM, ToddAndMargo wrote:

qx{ echo $Str | xclip -selection primary };

passes syntax, but hangs when run


Hi All,

I figured it out.  The reason the above "hangs" is
because it is "ambiguous".   What is Perl and what is
bash are not tightly delineated.  Is "$Str" the
name of a variable in the Bash shell or is it
resolved from Perl?  Is the pipe part of Perl or
part of Bash?  And while we are at it, who sees
the quotes?  And on and on and so forth.  It is
pull you hair out time.  You could "probably" eventually
figure it all out, but you would be complete bald
by the end.

But, not to fret.  To remove the "ambiguity", form the
shell command in a single variable first, then hand
the single variable to "shell".

For example:


sub WriteSecondaryClipboard ( $Str ) { # 
   my $Cmd = "echo \"$Str\" | xclip -selection clipboard";
   shell $Cmd;
}


problem solved.

Thank you all for all the help and tips.  I hope this helps
someone else.

-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

On 03/06/2017 02:21 AM, ToddAndMargo wrote:

Why is he
putting the commands into an array


He's being "fancy".



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

On 03/06/2017 12:20 AM, ToddAndMargo wrote:

qx{ echo $Str | xclip -selection primary };

passes syntax, but hangs when run


I figured it out.  I will get back later today with
and explanation and examples

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Is there a list out there of all the \n characters?

2017-03-06 Thread Parrot Raiser
"There's at least one program out there where someone apparently used
od on the output of a telnet session, saw an ancient hack for ancient
teletypes involving a NUL, and thought that was the "right" way to do
it"

Another technological Cheshire Cat bite. :-)*

On 3/6/17, Brandon Allbery  wrote:
> On Mon, Mar 6, 2017 at 12:35 PM, H.Merijn Brand 
> wrote:
>
>> But don't be surprised to see
>>
>>   \r\r\n
>>
>
> And other weird stuff. There's at least one program out there where someone
> apparently used od on the output of a telnet session, saw an ancient hack
> for ancient teletypes involving a NUL, and thought that was the "right" way
> to do it
>
> --
> brandon s allbery kf8nh   sine nomine
> associates
> allber...@gmail.com
> ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>


Re: Is there a list out there of all the \n characters?

2017-03-06 Thread Brandon Allbery
On Mon, Mar 6, 2017 at 12:35 PM, H.Merijn Brand  wrote:

> But don't be surprised to see
>
>   \r\r\n
>

And other weird stuff. There's at least one program out there where someone
apparently used od on the output of a telnet session, saw an ancient hack
for ancient teletypes involving a NUL, and thought that was the "right" way
to do it

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Is there a list out there of all the \n characters?

2017-03-06 Thread H.Merijn Brand
On Mon, 6 Mar 2017 18:08:47 +0100, Luca Ferrari 
wrote:

> On Mon, Mar 6, 2017 at 11:14 AM, ToddAndMargo  wrote:
> > Hi All,
> >
> > Is there a list of all the \n pairs out there somewhere?
> >  
> 
> Not sure, but if you mean a newline than I'm aware only of:
> - \n (unix)
> - \r\n (dos)
> - \n\r (old mac)
> 
> At least I'm not unlucky enough to have encountered another combination.
> 
> Luca

Don't rule out the idiots :)

0aLINE FEED
0cFORM FEED
0dCARRIAGE RETURN
1eRECORD SEPARATOR
1fUNIT SEPARATOR
8dREVERSE LINE FEED
002028LINE SEPARATOR
0023ce ⏎  RETURN SYMBOL
00240a ␊  SYMBOL FOR LINE FEED
00240c ␌  SYMBOL FOR FORM FEED
00240d ␍  SYMBOL FOR CARRIAGE RETURN
00241e ␞  SYMBOL FOR RECORD SEPARATOR
00241f ␟  SYMBOL FOR UNIT SEPARATOR
002424 ␤  SYMBOL FOR NEWLINE
002b90RETURN LEFT
002b91RETURN RIGHT
002b92NEWLINE LEFT
002b93NEWLINE RIGHT
003037IDEOGRAPHIC TELEGRAPH LINE FEED SEPARATOR SYMBOL
004dd7HEXAGRAM FOR RETURN

Other than that, I am not aware of other default combinations than

  \n
  \r\n
  \r

But don't be surprised to see

  \r\r\n

On files written by perl5 on Windows with "\r\n" as $/ (for safety
reasons, so people on Windows can read the text too HaHa), as the
default ":crlf" layer converts the \n in \r\n into \r\n resulting
in a doubled \r

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.25   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/


pgpuxxDgb8Bf6.pgp
Description: OpenPGP digital signature


Re: Is there a list out there of all the \n characters?

2017-03-06 Thread Brandon Allbery
On Mon, Mar 6, 2017 at 12:08 PM, Luca Ferrari  wrote:

> - \n\r (old mac)


Pre-OS X used simply \r. not \n\r.


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Is there a list out there of all the \n characters?

2017-03-06 Thread Luca Ferrari
On Mon, Mar 6, 2017 at 11:14 AM, ToddAndMargo  wrote:
> Hi All,
>
> Is there a list of all the \n pairs out there somewhere?
>

Not sure, but if you mean a newline than I'm aware only of:
- \n (unix)
- \r\n (dos)
- \n\r (old mac)

At least I'm not unlucky enough to have encountered another combination.

Luca


Re: Is there a list out there of all the \n characters?

2017-03-06 Thread Will Coleda
Can you clarify the request here, I'm not sure what you mean.

On Mon, Mar 6, 2017 at 5:14 AM, ToddAndMargo  wrote:
> Hi All,
>
> Is there a list of all the \n pairs out there somewhere?
>
> Many thanks,
> -T



-- 
Will "Coke" Coleda


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

On 03/06/2017 01:55 AM, Timo Paulssen wrote:

Is there a way to send and "end of file" marker to terminate the pipe?


That is exactly what the call to .close does.



Looking over at

https://github.com/kmwallio/p6-OS-Clipboard/blob/master/lib/OS/Clipboard.pm6
lines 47 to 52


  sub clipboard-copy(Str $content) is export {
my @command = 'echo "', clipboard-slash($content), '"|', 
clipboard-current();

my $result = shell @command.join(' ');
$win_pasteboard = $content;
return $result;
  }


"clipboard-current()" resolves to "xclip".

And I have no idea what he is doing.  Why is he
putting the commands into an array, then joining
the array with a space delimiter, when he calls
"shell"?

I am confused.

:'(

-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Is there a list out there of all the \n characters?

2017-03-06 Thread ToddAndMargo

Hi All,

Is there a list of all the \n pairs out there somewhere?

Many thanks,
-T


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread Timo Paulssen
> Is there a way to send and "end of file" marker to terminate the pipe?

That is exactly what the call to .close does.


Re: $*DISTRO

2017-03-06 Thread ToddAndMargo

On 03/06/2017 01:35 AM, Timo Paulssen wrote:

Doesn't seem to be, but there's $*DISTRO.is-win, which is usually enough
(i.e. you have to do one dumb thing on windows and another sane thing on
literally anything else)



Thank you!


--
~
I am Windows
I am the Blue Screen of Death
No one hears your screams
~


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

On 03/06/2017 01:32 AM, Timo Paulssen wrote:

This is because of how xclip works. It keeps running until you kill it,
or until the number of pastes has been reached that you specify with -loops.

You will want to use Proc::Async or run with an :in parameter instead of
shelling into a redirect with echo, here's why:

timo@schmand ~> cat BadFile.txt
cat: BadFile.txt: No such file or directory
timo@schmand ~ [1]> perl6 -e 'my $Str = "hello | touch BadFile.txt";
qqx{ echo $Str | xclip -selection primary }'
^C⏎
timo@schmand ~ [130]> cat BadFile.txt
timo@schmand ~>

See how just by giving a specially crafted string it created a file on
my filesystem?

Anyway, here's code that will work:

perl6 -e 'my $Str = "hello | touch BadFile.txt"; my $proc = run
, :in, :out;  $proc.in.say: $Str;
$proc.in.close; $proc.out.slurp-rest(:close);

This variant waits for the text to be pasted once. If you have something
like a clipboard manager (Klipper, for example), it'll probably
immediately grab your text and keep it for other programs to take.
Otherwise you'll have to paste the text once to other programs for it to
exit. When the user selects something else with the primary selection
xclip will exit, too.

The only reason it has :out is because otherwise there's no built-in way
to wait for it to exit. (I'm filing this as a bug, i think.)

If you want to be able to paste the text as often as you want, you'll
have to remove the -loops 1 part of the commandline and manually decide
when to .kill it.

It's also required that you close the $proc.in handle, because otherwise
xclip will keep waiting for more data and not actually offer anything to
the clipboard.

Hope that helps!
  - Timo


Is there a way to send and "end of file" marker to terminate the pipe?

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: $*DISTRO

2017-03-06 Thread ToddAndMargo

On 03/06/2017 01:40 AM, Steve Mynott wrote:

Try  $*KERNEL

S



Hi Steve,

That works!  Thank you!

-T


$ perl6 -e ' say $*KERNEL;'
linux (3.10.0.514.6.1.el.7.x.86._.64)

C:\perl6 -e "say $*KERNEL;"
win32

By the way win64 also give win32 including with the 64 bit raku

Don't know if I will ever write anything for weird old Mac though


Re: $*DISTRO

2017-03-06 Thread Steve Mynott
Try  $*KERNEL

S

On 6 March 2017 at 09:10, ToddAndMargo  wrote:
> Hi All,
>
> Is there a $*DISTRO or some such that will tell me just "linux"
> and not "rhel ..." or "fedora ..."?
>
>
> Many thanks,
> -T
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



-- 
4096R/EA75174B Steve Mynott 


Re: $*DISTRO

2017-03-06 Thread Timo Paulssen
Doesn't seem to be, but there's $*DISTRO.is-win, which is usually enough
(i.e. you have to do one dumb thing on windows and another sane thing on
literally anything else)


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

On 03/06/2017 01:32 AM, Timo Paulssen wrote:

This is because of how xclip works. It keeps running until you kill it,
or until the number of pastes has been reached that you specify with -loops.

You will want to use Proc::Async or run with an :in parameter instead of
shelling into a redirect with echo, here's why:

timo@schmand ~> cat BadFile.txt
cat: BadFile.txt: No such file or directory
timo@schmand ~ [1]> perl6 -e 'my $Str = "hello | touch BadFile.txt";
qqx{ echo $Str | xclip -selection primary }'
^C⏎
timo@schmand ~ [130]> cat BadFile.txt
timo@schmand ~>

See how just by giving a specially crafted string it created a file on
my filesystem?

Anyway, here's code that will work:

perl6 -e 'my $Str = "hello | touch BadFile.txt"; my $proc = run
, :in, :out;  $proc.in.say: $Str;
$proc.in.close; $proc.out.slurp-rest(:close);

This variant waits for the text to be pasted once. If you have something
like a clipboard manager (Klipper, for example), it'll probably
immediately grab your text and keep it for other programs to take.
Otherwise you'll have to paste the text once to other programs for it to
exit. When the user selects something else with the primary selection
xclip will exit, too.

The only reason it has :out is because otherwise there's no built-in way
to wait for it to exit. (I'm filing this as a bug, i think.)

If you want to be able to paste the text as often as you want, you'll
have to remove the -loops 1 part of the commandline and manually decide
when to .kill it.

It's also required that you close the $proc.in handle, because otherwise
xclip will keep waiting for more data and not actually offer anything to
the clipboard.

Hope that helps!
  - Timo



Thank you!

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need the rules for qx with a pipe inside

2017-03-06 Thread Timo Paulssen
This is because of how xclip works. It keeps running until you kill it,
or until the number of pastes has been reached that you specify with -loops.

You will want to use Proc::Async or run with an :in parameter instead of
shelling into a redirect with echo, here's why:

timo@schmand ~> cat BadFile.txt
cat: BadFile.txt: No such file or directory
timo@schmand ~ [1]> perl6 -e 'my $Str = "hello | touch BadFile.txt";
qqx{ echo $Str | xclip -selection primary }'
^C⏎
timo@schmand ~ [130]> cat BadFile.txt
timo@schmand ~>

See how just by giving a specially crafted string it created a file on
my filesystem?

Anyway, here's code that will work:

perl6 -e 'my $Str = "hello | touch BadFile.txt"; my $proc = run
, :in, :out;  $proc.in.say: $Str;
$proc.in.close; $proc.out.slurp-rest(:close);

This variant waits for the text to be pasted once. If you have something
like a clipboard manager (Klipper, for example), it'll probably
immediately grab your text and keep it for other programs to take.
Otherwise you'll have to paste the text once to other programs for it to
exit. When the user selects something else with the primary selection
xclip will exit, too.

The only reason it has :out is because otherwise there's no built-in way
to wait for it to exit. (I'm filing this as a bug, i think.)

If you want to be able to paste the text as often as you want, you'll
have to remove the -loops 1 part of the commandline and manually decide
when to .kill it.

It's also required that you close the $proc.in handle, because otherwise
xclip will keep waiting for more data and not actually offer anything to
the clipboard.

Hope that helps!
  - Timo


$*DISTRO

2017-03-06 Thread ToddAndMargo

Hi All,

Is there a $*DISTRO or some such that will tell me just "linux"
and not "rhel ..." or "fedora ..."?


Many thanks,
-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


I need the rules for qx with a pipe inside

2017-03-06 Thread ToddAndMargo

qx{ echo $Str | xclip -selection primary };

passes syntax, but hangs when run