Re: zip mystery

2017-07-17 Thread ToddAndMargo

-Original Message-
From: ToddAndMargo [mailto:toddandma...@zoho.com]
Sent: Monday, July 17, 2017 8:29 PM
To: perl6-users 
Subject: Re: zip mystery


-Original Message-
From: ToddAndMargo [mailto:toddandma...@zoho.com]
Sent: Monday, July 17, 2017 8:19 PM
To: perl6-users 
Subject: zip mystery

Hi All,

This runs:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile",
"$DiagDir/BlankFile.txt", :out);


And this also works (bash)
zip -j eraseme.zip /opt/xxx/yyy/zzz/diags/*


But this does not:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile",
"$DiagDir/*", :out);

warning: name not matched: /opt/xxx/yyy/zzz/diags/*


What am I doing wrong?

Many thanks,
-T



On 07/17/2017 05:22 PM, Mark Devine wrote:

T,

What happens when you do this?

my $proc = run('zip', '-j', $ZipLog, $CimLog, $LogFile,  $DiagDir ~
'/*', :out);

Mark


with  $DiagDir ~ '/*'

warning: name not matched: /opt/Cimcor/CimTrak/CimTrakServer/diags/*




On 07/17/2017 05:33 PM, Mark Devine wrote:
> T,
>
> It appears to be a 'zip' error, not a Perl 6 issue.  Perhaps use 'zip 
-r' (explicit recursion) instead of '/*' (implicit "glob").

>
> Mark
>
>


Hi Mark,

-jr did the trick!

I had avoided trying it as I thought it would throw an error
as two of the requested entities were files and not
directories.  But the zip folks had already thought of
that and it worked perfectly.

Thank you!

-T

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


Re: zip mystery

2017-07-17 Thread ToddAndMargo
On Mon, Jul 17, 2017 at 8:18 PM, ToddAndMargo > wrote:


But this does not:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile",
"$DiagDir/*", :out);

warning: name not matched: /opt/xxx/yyy/zzz/diags/*

What am I doing wrong?



On 07/17/2017 05:45 PM, Brandon Allbery wrote:


run() does not use a shell. The shell is what understands that * and 
expands it to a list of matching files. If you want that expansion, use 
shell() or use Perl 6 to get the directory contents separately and send 
it along as a list (see https://docs.perl6.org/type/IO::Path#routine_dir).


Now I understand.  Thank you!


Re: zip mystery

2017-07-17 Thread Brandon Allbery
On Mon, Jul 17, 2017 at 8:18 PM, ToddAndMargo  wrote:

> But this does not:
>
> my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile",
> "$DiagDir/*", :out);
>
> warning: name not matched: /opt/xxx/yyy/zzz/diags/*
>
> What am I doing wrong?
>

run() does not use a shell. The shell is what understands that * and
expands it to a list of matching files. If you want that expansion, use
shell() or use Perl 6 to get the directory contents separately and send it
along as a list (see https://docs.perl6.org/type/IO::Path#routine_dir).

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


Re: zip mystery

2017-07-17 Thread ToddAndMargo

-Original Message-
From: ToddAndMargo [mailto:toddandma...@zoho.com]
Sent: Monday, July 17, 2017 8:19 PM
To: perl6-users 
Subject: zip mystery

Hi All,

This runs:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile", 
"$DiagDir/BlankFile.txt", :out);


And this also works (bash)
zip -j eraseme.zip /opt/xxx/yyy/zzz/diags/*


But this does not:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile",
"$DiagDir/*", :out);

warning: name not matched: /opt/xxx/yyy/zzz/diags/*


What am I doing wrong?

Many thanks,
-T



On 07/17/2017 05:22 PM, Mark Devine wrote:

T,

What happens when you do this?

my $proc = run('zip', '-j', $ZipLog, $CimLog, $LogFile,  $DiagDir ~ '/*', :out);

Mark


with  $DiagDir ~ '/*'

warning: name not matched: /opt/Cimcor/CimTrak/CimTrakServer/diags/*


zip mystery

2017-07-17 Thread ToddAndMargo

Hi All,

This runs:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile", 
"$DiagDir/BlankFile.txt", :out);



And this also works (bash)
zip -j eraseme.zip /opt/xxx/yyy/zzz/diags/*


But this does not:

my $proc = run('zip', '-j', "$ZipLog", "$CimLog", "$LogFile", 
"$DiagDir/*", :out);


warning: name not matched: /opt/xxx/yyy/zzz/diags/*


What am I doing wrong?

Many thanks,
-T


Re: String to array problem

2017-07-17 Thread Brandon Allbery
And this is another reason for the Grammar solution: it lets you do just
what is needed, in a constrained environment so you don't have any risk
(unless you do something questionable in the Grammar, but then that's on
you.)

On Mon, Jul 17, 2017 at 6:15 AM, Brent Laabs  wrote:

> Just to make it clear, do not use EVAL() ever on untrusted user input.  In
> the example I wrote, if the string contained a '>', anything after that
> point would be executed.  While it works, it's a bad idea to use it.
>
> On Mon, Jul 17, 2017 at 2:17 AM, ToddAndMargo 
> wrote:
>
>> On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo > wrote:

 On 07/16/2017 07:48 PM, Brent Laabs wrote:

 $ perl6
> my $x='ls -al "Program Files" "Moe Curly Larry"';
 ls -al "Program Files" "Moe Curly Larry"
> ( "qww<$x>" ).perl
 ("ls", "-al", "Program Files", "Moe Curly Larry")

 How about this?  Obligatory: Much EVAL, very danger wow.


 I don't understand.  Would you put this into a full executable
 example?



>> On 07/17/2017 02:08 AM, Brent Laabs wrote:
>>
>>> I would put it in an executable example, and I already did.  But here's
>>> another one, if you like.
>>>
>>> $ perl6 -e 'my $x = q; my @y =
>>> ( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'
>>>@y[0] = 'ls'
>>>@y[1] = '-al'
>>>@y[2] = 'Program Files'
>>>@y[3] = 'Moe Curly Larry'
>>>
>>> The last loop is just so it's printed in the way you demonstrated in the
>>> first post.
>>>
>>> The main point of me writing that example in the first place is because
>>> I know that the Perl 6 language itself is very good at parsing quotes.  If
>>> you knew what the string was at compile time, you could just write this:
>>>   my @y = qww;
>>> And it would know exactly how to deal with the quotes.  But I don't know
>>> how to access this functionality of the quote language from within the Perl
>>> 6 language.  You can't use qqww directly, because the quote protection is
>>> handled before interpolation, and we want it to happen after.  So I can
>>> eval a qww string instead, and that does work, though it does recognize
>>> kinds of quoting that you wouldn't expect, like dumb quotes or halfwidth
>>> katakana quotes.
>>>
>>> All of this is to say that I wish the Str.words method had a way of
>>> applying Perl 6 quoting rules as if it were the qww operator.
>>>
>>>
>> Thank you!
>>
>>
>> --
>> ~~
>> Computers are like air conditioners.
>> They malfunction when you open windows
>> ~~
>>
>
>


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


Re: String to array problem

2017-07-17 Thread Brent Laabs
Just to make it clear, do not use EVAL() ever on untrusted user input.  In
the example I wrote, if the string contained a '>', anything after that
point would be executed.  While it works, it's a bad idea to use it.

On Mon, Jul 17, 2017 at 2:17 AM, ToddAndMargo  wrote:

> On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo >> > wrote:
>>>
>>> On 07/16/2017 07:48 PM, Brent Laabs wrote:
>>>
>>> $ perl6
>>>> my $x='ls -al "Program Files" "Moe Curly Larry"';
>>> ls -al "Program Files" "Moe Curly Larry"
>>>> ( "qww<$x>" ).perl
>>> ("ls", "-al", "Program Files", "Moe Curly Larry")
>>>
>>> How about this?  Obligatory: Much EVAL, very danger wow.
>>>
>>>
>>> I don't understand.  Would you put this into a full executable
>>> example?
>>>
>>>
>>>
> On 07/17/2017 02:08 AM, Brent Laabs wrote:
>
>> I would put it in an executable example, and I already did.  But here's
>> another one, if you like.
>>
>> $ perl6 -e 'my $x = q; my @y =
>> ( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'
>>@y[0] = 'ls'
>>@y[1] = '-al'
>>@y[2] = 'Program Files'
>>@y[3] = 'Moe Curly Larry'
>>
>> The last loop is just so it's printed in the way you demonstrated in the
>> first post.
>>
>> The main point of me writing that example in the first place is because I
>> know that the Perl 6 language itself is very good at parsing quotes.  If
>> you knew what the string was at compile time, you could just write this:
>>   my @y = qww;
>> And it would know exactly how to deal with the quotes.  But I don't know
>> how to access this functionality of the quote language from within the Perl
>> 6 language.  You can't use qqww directly, because the quote protection is
>> handled before interpolation, and we want it to happen after.  So I can
>> eval a qww string instead, and that does work, though it does recognize
>> kinds of quoting that you wouldn't expect, like dumb quotes or halfwidth
>> katakana quotes.
>>
>> All of this is to say that I wish the Str.words method had a way of
>> applying Perl 6 quoting rules as if it were the qww operator.
>>
>>
> Thank you!
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


Re: String to array problem

2017-07-17 Thread ToddAndMargo
On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo > wrote:


On 07/16/2017 07:48 PM, Brent Laabs wrote:

$ perl6
   > my $x='ls -al "Program Files" "Moe Curly Larry"';
ls -al "Program Files" "Moe Curly Larry"
   > ( "qww<$x>" ).perl
("ls", "-al", "Program Files", "Moe Curly Larry")

How about this?  Obligatory: Much EVAL, very danger wow.


I don't understand.  Would you put this into a full executable example?




On 07/17/2017 02:08 AM, Brent Laabs wrote:
I would put it in an executable example, and I already did.  But here's 
another one, if you like.


$ perl6 -e 'my $x = q; my @y = 
( "qww<$x>"); for @y.kv -> $i, $j { say "  \@y[$i] = \c39$j\c39" }'

   @y[0] = 'ls'
   @y[1] = '-al'
   @y[2] = 'Program Files'
   @y[3] = 'Moe Curly Larry'

The last loop is just so it's printed in the way you demonstrated in the 
first post.


The main point of me writing that example in the first place is because 
I know that the Perl 6 language itself is very good at parsing quotes.  
If you knew what the string was at compile time, you could just write this:

  my @y = qww;
And it would know exactly how to deal with the quotes.  But I don't know 
how to access this functionality of the quote language from within the 
Perl 6 language.  You can't use qqww directly, because the quote 
protection is handled before interpolation, and we want it to happen 
after.  So I can eval a qww string instead, and that does work, though 
it does recognize kinds of quoting that you wouldn't expect, like dumb 
quotes or halfwidth katakana quotes.


All of this is to say that I wish the Str.words method had a way of 
applying Perl 6 quoting rules as if it were the qww operator.




Thank you!

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


Re: String to array problem

2017-07-17 Thread Elizabeth Mattijsen
> On 17 Jul 2017, at 11:08, Brent Laabs  wrote:
> All of this is to say that I wish the Str.words method had a way of applying 
> Perl 6 quoting rules as if it were the qww operator.

Wouldn’t that be either .split or .comb?


Liz