Re: sleep 3600 vs task scheduler

2020-04-07 Thread ToddAndMargo via perl6-users

On 2020-04-07 20:39, Paul Procacci wrote:

What happens when you try it?
What impact do you observe?

My guess is the impact is exactly the time it takes for your cpu to 
perform the initial context switch for the syscall, and then another 
when waking up.


Hi Paul,

I opened the resource monitor and watched the CPU load:

raku -e "say 'start sleep 10'; sleep 10; say 'stop sleep;'"
start sleep 10
stop sleep;

Nothing.  Sleep must be recovering using a system interrupt.
Yippee!

-T


Re: sleep 3600 vs task scheduler

2020-04-07 Thread Paul Procacci
What happens when you try it?
What impact do you observe?

My guess is the impact is exactly the time it takes for your cpu to perform
the initial context switch for the syscall, and then another when waking up.

On Tue, Apr 7, 2020 at 10:28 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> >> On Tue, Apr 7, 2020 at 6:02 AM ToddAndMargo via perl6-users
> >> mailto:perl6-users@perl.org>> wrote:
> >>
> >> Hi All,
> >>
> >> Windows 7/10
> >>
> >> Another piece of the puzzle.
> >>
> >> I want to loop Raku program once an hour.
> >>
> >> Is it better use `sleep 3600` or let the program
> >> die and restart every hour from the Task Scheduler.
> >> By better, I mean less of a CPU footprint.
> >>
> >> `sleep` would allow the user to cancel the program
> >> and not have it come back.
> >>
> >> Many thanks,
> >> -T
> >>
>
> On 2020-04-07 19:22, Brad Gilbert wrote:
> > Run code once an hour:
> >
> >  react whenever Supply.interval(60 * 60) {
> >  say "it's been an hour"
> >  }
> >
> > Right now that gets about 0.01 seconds slower every time the interval
> runs.
> > (At least on my computer.)
> > So it will get 1 second later every 4 days.
> >
> >
> > Or if you want more precise control, you could do something like:
> >
> > Here is an example that is more accurate, and happens at the top of the
> > hour:
> >
> >  sub every-hour ( --> Supply:D ) {
> >  supply {
> >  sub add-next ( $hour --> Nil ) {
> >  whenever Promise.at( $hour.Instant ) {
> >  emit $hour;
> >  add-next( $hour.later(:1hour) );
> >  }
> >  }
> >
> >  add-next( DateTime.now.truncated-to('hour').later( :1hour )
> );
> >  }
> >  }
> >
> >
> >  react whenever every-hour() {
> >  say "it's been an hour";
> >  say "the time is $_"
> >  }
> >
> >
> >
> > Honestly it would probably be better to use something native to the
> > system to run it once an hour, in case the program dies.
> >
> >
>
> Thank you!
>
> How much impact CPU usage wise does sleep and/or react
> have on the system?
>
> My fear is I will tie up a core with my code
>


-- 
__

:(){ :|:& };:


Re: sleep 3600 vs task scheduler

2020-04-07 Thread ToddAndMargo via perl6-users
On Tue, Apr 7, 2020 at 6:02 AM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

Windows 7/10

Another piece of the puzzle.

I want to loop Raku program once an hour.

Is it better use `sleep 3600` or let the program
die and restart every hour from the Task Scheduler.
By better, I mean less of a CPU footprint.

`sleep` would allow the user to cancel the program
and not have it come back.

Many thanks,
-T



On 2020-04-07 19:22, Brad Gilbert wrote:

Run code once an hour:

     react whenever Supply.interval(60 * 60) {
         say "it's been an hour"
     }

Right now that gets about 0.01 seconds slower every time the interval runs.
(At least on my computer.)
So it will get 1 second later every 4 days.


Or if you want more precise control, you could do something like:

Here is an example that is more accurate, and happens at the top of the 
hour:


     sub every-hour ( --> Supply:D ) {
         supply {
             sub add-next ( $hour --> Nil ) {
                 whenever Promise.at( $hour.Instant ) {
                     emit $hour;
                     add-next( $hour.later(:1hour) );
                 }
             }

             add-next( DateTime.now.truncated-to('hour').later( :1hour ) );
         }
     }


     react whenever every-hour() {
         say "it's been an hour";
         say "the time is $_"
     }



Honestly it would probably be better to use something native to the 
system to run it once an hour, in case the program dies.





Thank you!

How much impact CPU usage wise does sleep and/or react
have on the system?

My fear is I will tie up a core with my code


Re: How to read a particular environmental variable?

2020-04-07 Thread ToddAndMargo via perl6-users

On 2020-04-07 18:25, Brad Gilbert wrote:

Of course %*ENV is case sensitive, hashes are case sensitive.

     say %*ENV.^name; # Hash

%*ENV gets populated with the values before your code runs.
Other than that it is fairly ordinary.


My purpose for the case sensitive remark was that
environmental variables are not case sensitive in
Windows.  And I do not know how Raku interacts with
them.

>echo %WINDIR%
C:\WINDOWS

>echo %windir%
C:\WINDOWS

>echo %WinDir%
C:\WINDOWS


Re: sleep 3600 vs task scheduler

2020-04-07 Thread Brad Gilbert
Run code once an hour:

react whenever Supply.interval(60 * 60) {
say "it's been an hour"
}

Right now that gets about 0.01 seconds slower every time the interval runs.
(At least on my computer.)
So it will get 1 second later every 4 days.


Or if you want more precise control, you could do something like:

Here is an example that is more accurate, and happens at the top of the
hour:

sub every-hour ( --> Supply:D ) {
supply {
sub add-next ( $hour --> Nil ) {
whenever Promise.at( $hour.Instant ) {
emit $hour;
add-next( $hour.later(:1hour) );
}
}

add-next( DateTime.now.truncated-to('hour').later( :1hour ) );
}
}


react whenever every-hour() {
say "it's been an hour";
say "the time is $_"
}



Honestly it would probably be better to use something native to the system
to run it once an hour, in case the program dies.


On Tue, Apr 7, 2020 at 6:02 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> Windows 7/10
>
> Another piece of the puzzle.
>
> I want to loop Raku program once an hour.
>
> Is it better use `sleep 3600` or let the program
> die and restart every hour from the Task Scheduler.
> By better, I mean less of a CPU footprint.
>
> `sleep` would allow the user to cancel the program
> and not have it come back.
>
> Many thanks,
> -T
>


Re: Dropbox and IO?

2020-04-07 Thread ToddAndMargo via perl6-users

On 2020-04-07 09:29, Stephen Wilcoxon wrote:
Dropbox on Windows is a real directory.  It is just monitored by the 
Dropbox software and files (or possibly pieces - not sure) are uploaded 
and downloaded when necessary to keep them in sync with the server.


Confirmed!  Thank you all for the tips!


Re: How to read a web page?

2020-04-07 Thread ToddAndMargo via perl6-users

> On Tue, Apr 7, 2020 at 1:58 PM ToddAndMargo via perl6-users
> mailto:perl6-users@perl.org>> wrote:
>
> On 2020-04-07 02:55, Veesh Goldman wrote:
>  > Your question is way to vague. What do you actually want to do?
> If you
>  > just wanna download a page, use curl or some other tool, no
> reason to do
>  > it from raku if there's nothing more than that.
>  > If you want more than that, then please be more specific.
>
> Hi Veesh,
>
> Sorry for the confusion.  I only wanted a small
> piece of a puzzle I am putting together.
>
> This big picture is this.
>
> I have a customer that runs RDP (Remote Desktop Protocol)
> server on Window 7.  He logs into this server with
> a Window 10 Pro laptop from all around the country using
> mstsc.exe and WFreeRDP.
>
> His new Internet provider at this house will use
> dynamic (floating) WAN (Wide Area Network) IP's.
>
> And he uses DropBox.  So I am writing a raku program
> on his RDP server to upload his WAN IP to Dropbox
> once an hour and another program on his RDP client
> to read the drop box file and wrap mstsc and WFree
> RDP with his server's WAN address.
>
> That is also why I asked the DropBox question.
> (DropBox works marvelously on Fedora 31).  But
> Since Drop Box and Cobian Backup on Windows
> don't mesh, I am being extra careful. (I think
> the issue is Cobain's use of Volume Shadow
> Copy Service.)
>
> -T
>

On 2020-04-07 05:43, Veesh Goldman wrote:
Are you familiar with dynamic dns providers like duckdns.org 
 (there are others, too). That coupled with a script 
that updates your ip with the provider, like ddclient (written in 
perl!), should be a more straightforward way of accomplishing what you want.
Also, thank you for clarifying what you are trying to do. Because the 
answer changes a lot once you want to parse the page that you download.




Hi Veesh,

I have looked at services like that.  I like the Raku
route better as I can do everything very seamlessly:
automatic WAN address check and update, top loading
and pruning log file of WAN address changes, automatic
creating of mstsc and WFreeRDP run stings, ignore
and warn if the Internet is down, etc..  All the user has
to do it click on an icon.  Other than which icon to
click on, no other user interaction.

It would help if the developers would implement:

RFE: shell / no shell switch
https://github.com/rakudo/rakudo/issues/3582

-T

And you guys wonder what I did with all the help you
have been giving me!


Re: How to read a particular environmental variable?

2020-04-07 Thread Brad Gilbert
Of course %*ENV is case sensitive, hashes are case sensitive.

say %*ENV.^name; # Hash

%*ENV gets populated with the values before your code runs.
Other than that it is fairly ordinary.

On Tue, Apr 7, 2020 at 7:20 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> >> On Tue, Apr 7, 2020 at 6:48 PM ToddAndMargo via perl6-users
> >> mailto:perl6-users@perl.org>> wrote:
> >>
> >> Hi All,
> >>
> >> $ raku -e 'say %*ENV;'
> >>
> >> Gives me ALL of them.  Is there a way to just ask for
> >> a particular one, such as %appdata%, or %userprofile%
> >> in Windows or $HOME is Linux?
> >>
> >> Many thanks,
> >> -T
> >>
>
> On 2020-04-07 16:05, Gerard ONeill wrote:
> > It’s still a hash — the * twigil tweaks it’s scope, but it is still a %
> > — so %*ENV works (windows)
> >
> >
> Hi Gerald,
>
> Ah Ha!  Thank you!
>
> Windows 10:
>
> raku -e "say %*ENV;"
> C:\Users\todd\AppData\Roaming
>
>
> Fedora:
> $ raku -e 'say %*ENV;'
> /home/tony
>
> Oh, and both WIndows and Fedora (Linux) are case
> sensititive
>
> Love Hashes.  My favorite variable structure.
>
> -T
>


Re: How to read a particular environmental variable?

2020-04-07 Thread ToddAndMargo via perl6-users
On Tue, Apr 7, 2020 at 6:48 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

$ raku -e 'say %*ENV;'

Gives me ALL of them.  Is there a way to just ask for
a particular one, such as %appdata%, or %userprofile%
in Windows or $HOME is Linux?

Many thanks,
-T



On 2020-04-07 16:05, Gerard ONeill wrote:
It’s still a hash — the * twigil tweaks it’s scope, but it is still a % 
— so %*ENV works (windows)




Hi Gerald,

Ah Ha!  Thank you!

Windows 10:

   raku -e "say %*ENV;"
   C:\Users\todd\AppData\Roaming


Fedora:
   $ raku -e 'say %*ENV;'
   /home/tony

Oh, and both WIndows and Fedora (Linux) are case
sensititive

Love Hashes.  My favorite variable structure.

-T


Re: Can a sub be released?

2020-04-07 Thread Brad Gilbert
You do NOT want to use `fork`.
MoarVM has several threads that are running, and `fork` doesn't handle that.

A simple way is to just use the `start` statement prefix

sub child-process () {
sleep 2;
say 'child says hi'
}

say 'starting child';
start child-process();

for ^10 {
say ++$;
sleep .5;
}
say 'ending program';

Which will result in something like:

starting child
1
2
3
4
child says hi
5
6
7
8
9
10
ending program

The program will exit when the mainline finishes. So if you didn't have the
loop, the program will exit before the child prints anything.

You could directly call `$*SCHEDULER.cue()` instead.
Which has adverbs such as `every`, `times`, `at`, `in`, and `catch`

If you use one of the adverbs other than `catch`, it will return
a Cancellation object which would allow you to stop a thread that hasn't
started running yet.

On Tue, Apr 7, 2020 at 4:19 PM yary  wrote:

> They way I remember it (taught to me waaay back when) is that, you fork
> twice, and the grandchild process that lives on becomes a daemon whose
> parent is the system "init" process, PID 1, after the parent and
> 1st-generation child process exit. Found general concept at
> http://www.farhadsaberi.com/perl/2013/02/perl-detach-process-daemon.html
>
> How to implement that in raku, and if it works as intended in Windows...
> is left as an exercise to the reader!
>
> -y
>
>
> On Tue, Apr 7, 2020 at 2:42 PM Paul Procacci  wrote:
>
>> https://docs.perl6.org/language/5to6-perlfunc#fork
>> https://docs.perl6.org/type/Thread
>>
>> I haven't tried myself but it's conceivable that you can start a new
>> thread that exec's some external program.
>>
>> On Tue, Apr 7, 2020 at 7:21 AM ToddAndMargo via perl6-users <
>> perl6-users@perl.org> wrote:
>>
>>> Hi All,
>>>
>>> Can a subroutine be released from the main program
>>> to go off on its own?  (Is this called "forked"?)
>>>
>>> If not how do I do a `qqx` or a `run` that releases
>>> the program to go off on its own?
>>>
>>> Many thanks,
>>> -T
>>>
>>
>>
>> --
>> __
>>
>> :(){ :|:& };:
>>
>


Re: How to read a particular environmental variable?

2020-04-07 Thread Gerard ONeill
It’s still a hash — the * twigil tweaks it’s scope, but it is still a % —
so %*ENV works (windows)


On Tue, Apr 7, 2020 at 6:48 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> $ raku -e 'say %*ENV;'
>
> Gives me ALL of them.  Is there a way to just ask for
> a particular one, such as %appdata%, or %userprofile%
> in Windows or $HOME is Linux?
>
> Many thanks,
> -T
>


Re: Can a sub be released?

2020-04-07 Thread ToddAndMargo via perl6-users
On Tue, Apr 7, 2020 at 7:21 AM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

Can a subroutine be released from the main program
to go off on its own?  (Is this called "forked"?)

If not how do I do a `qqx` or a `run` that releases
the program to go off on its own?

Many thanks,
-T


On 2020-04-07 11:42, Paul Procacci wrote:

https://docs.perl6.org/language/5to6-perlfunc#fork
https://docs.perl6.org/type/Thread

I haven't tried myself but it's conceivable that you can start a new 
thread that exec's some external program.




Thank you!


How to read a particular environmental variable?

2020-04-07 Thread ToddAndMargo via perl6-users

Hi All,

$ raku -e 'say %*ENV;'

Gives me ALL of them.  Is there a way to just ask for
a particular one, such as %appdata%, or %userprofile%
in Windows or $HOME is Linux?

Many thanks,
-T


Re: Can a sub be released?

2020-04-07 Thread yary
They way I remember it (taught to me waaay back when) is that, you fork
twice, and the grandchild process that lives on becomes a daemon whose
parent is the system "init" process, PID 1, after the parent and
1st-generation child process exit. Found general concept at
http://www.farhadsaberi.com/perl/2013/02/perl-detach-process-daemon.html

How to implement that in raku, and if it works as intended in Windows... is
left as an exercise to the reader!

-y


On Tue, Apr 7, 2020 at 2:42 PM Paul Procacci  wrote:

> https://docs.perl6.org/language/5to6-perlfunc#fork
> https://docs.perl6.org/type/Thread
>
> I haven't tried myself but it's conceivable that you can start a new
> thread that exec's some external program.
>
> On Tue, Apr 7, 2020 at 7:21 AM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> Hi All,
>>
>> Can a subroutine be released from the main program
>> to go off on its own?  (Is this called "forked"?)
>>
>> If not how do I do a `qqx` or a `run` that releases
>> the program to go off on its own?
>>
>> Many thanks,
>> -T
>>
>
>
> --
> __
>
> :(){ :|:& };:
>


Re: Can a sub be released?

2020-04-07 Thread Paul Procacci
https://docs.perl6.org/language/5to6-perlfunc#fork
https://docs.perl6.org/type/Thread

I haven't tried myself but it's conceivable that you can start a new thread
that exec's some external program.

On Tue, Apr 7, 2020 at 7:21 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> Can a subroutine be released from the main program
> to go off on its own?  (Is this called "forked"?)
>
> If not how do I do a `qqx` or a `run` that releases
> the program to go off on its own?
>
> Many thanks,
> -T
>


-- 
__

:(){ :|:& };:


Re: unflattering flat

2020-04-07 Thread yary
I left out first line in the example REPL

> my %hash-with-arrays = a => [1,2], b => [3,4], c=>5, d=>[6,[7,8]]
{a => [1 2], b => [3 4], c => 5, d => [6 [7 8]]}
> say gather %hash-with-arrays.values.deepmap: { .take }
(6 7 8 1 2 3 4 5)
> say   %hash-with-arrays.values>>[].flat
(6 [7 8] 1 2 3 4 5)


Re: unflattering flat

2020-04-07 Thread yary
Larry all looks good with the latest email and encoding!

Interpreting  %hash-with-arrays.values>>[].flat aka
%hash-with-arrays.values»[].flat

>> is hyperoperator
https://docs.raku.org/language/operators#index-entry-hyper_
<<-hyper_>>-hyper_«-hyper_»-Hyper_operators
and as for [] "it's the postcircumfix[]
 which is being
hypered."
it is "The Array  constructor returns an
itemized Array  that does not flatten in
list context."
And then, call "flat" on the resulting itemized Arrays.

> say gather %hash-with-arrays.values.deepmap: { .take }
(6 7 8 1 2 3 4 5)
> say %hash-with-arrays.values>>[].flat
(6 [7 8] 1 2 3 4 5)

Happy with those!

ps. :-) I now see Ralph's comment including
"microwave+garlic+to+remove+skin" as poetic, referring to both removing the
"item" skins and the Unicode garlic ideogram

-y


On Tue, Apr 7, 2020 at 12:15 PM Larry Wall  wrote:

> On Mon, Apr 06, 2020 at 08:04:45PM -0400, yary wrote:
> : Larry's answer came through my browser with munged Unicode, it looks like
> : this
> :
> : [image: image.png]
> : - with the Chinese character for "garlic" after the word "values"
>
> I wrote the Unicode equivalent of:
>
> %hash-with-arrays.values>>[].flat
>
> but for some reason mutt translated it to latin-1, which your mail program
> apparently doesn't grok.
>
> Maybe if I actually put a Chinese character in like 楽 it will leave it in
> UTF-8?
>
> Testing:
>
> %hash-with-arrays.values»[].flat
>
> Larry
>


Re: unflattering flat

2020-04-07 Thread Larry Wall
On Tue, Apr 07, 2020 at 09:15:06AM -0700, Larry Wall wrote:
: Maybe if I actually put a Chinese character in like 楽 it will leave it in 
UTF-8?

Oops, actually, now that I think about it, 楽 (raku) is a Japanese-only 
character.
The Chinese equivalents are traditional 樂 and simplified 乐.

I really don't know why the browsers would be translating »[ to chinese.
The first message I sent clearly says:

Content-Type: text/plain; charset=iso-8859-1

so the browsers should be able to display a latin-1 » character.  If you
save the message to a file. the file command identifies it as iso-8859,
and vim also interprets it as iso-8859-1, and correctly displays the ».
Catting the file to the terminal doesn't work, so it's not encoded
in utf-8 accidentally.

So I think it has to be your browser or gmail in error...

Larry


Re: Dropbox and IO?

2020-04-07 Thread Stephen Wilcoxon
Dropbox on Windows is a real directory.  It is just monitored by the
Dropbox software and files (or possibly pieces - not sure) are uploaded and
downloaded when necessary to keep them in sync with the server.

On Tue, Apr 7, 2020 at 2:40 AM Simon Proctor 
wrote:

> Ok I don't have access to my windows box until this evening. I'm mostly
> used to using Dropbox on a Linux box where it's just a folder.
>
> Sorry for my mistake.
>
> On Tue, 7 Apr 2020 at 07:51, Shlomi Fish  wrote:
>
>> Hi Simon,
>>
>> On Tue, 7 Apr 2020 06:55:00 +0100
>> Simon Proctor  wrote:
>>
>> > Don't see why not, Dropbox is just a folder that you should be able to
>> > access as normal.
>> >
>>
>> Is it a higher-level folder or a bona-fide filesystem direcory:
>>
>> https://en.wikipedia.org/wiki/Directory_(computing)#Folder_metaphor
>>
>> If it is not visible to the filesystem, one may need higher level APIs
>> other
>> than fopen ( https://en.cppreference.com/w/c/io/fopen ) and friends.
>>
>> > On Tue, 7 Apr 2020, 02:22 ToddAndMargo via perl6-users, <
>> > perl6-users@perl.org> wrote:
>> >
>> > > Hi All,
>> > >
>> > > Do any of you using Windows and Dropbox know
>> > > if Raku's file IO utilities can both read
>> > > and write to a Drop Box drive?
>> > >
>> > > Many thanks,
>> > > -T
>> > >
>>
>>
>>
>> --
>>
>> Shlomi Fish   https://www.shlomifish.org/
>> https://www.shlomifish.org/open-source/resources/tech-tips/
>>
>> How many “one-liners” do I actually write? I don’t know; maybe a couple
>> dozen
>> a day. But I guess I must be unusual, because as we all know, AWK was a
>> complete failure and vanished into obscurity since it didn’t address
>> anyone’s
>> real needs. (That was sarcasm.) — “Twelve Views of Mark Jason Dominus”
>>
>> Please reply to list if it's a mailing list post - https://shlom.in/reply
>> .
>>
>
>
> --
> Simon Proctor
> Cognoscite aliquid novum cotidie
>
> http://www.khanate.co.uk/
>


Re: unflattering flat

2020-04-07 Thread Larry Wall
On Mon, Apr 06, 2020 at 08:04:45PM -0400, yary wrote:
: Larry's answer came through my browser with munged Unicode, it looks like
: this
: 
: [image: image.png]
: - with the Chinese character for "garlic" after the word "values"

I wrote the Unicode equivalent of:

%hash-with-arrays.values>>[].flat

but for some reason mutt translated it to latin-1, which your mail program
apparently doesn't grok.

Maybe if I actually put a Chinese character in like 楽 it will leave it in UTF-8?

Testing:

%hash-with-arrays.values»[].flat

Larry


Re: How to read a web page?

2020-04-07 Thread Veesh Goldman
Are you familiar with dynamic dns providers like duckdns.org (there are
others, too). That coupled with a script that updates your ip with the
provider, like ddclient (written in perl!), should be a more
straightforward way of accomplishing what you want.
Also, thank you for clarifying what you are trying to do. Because the
answer changes a lot once you want to parse the page that you download.

On Tue, Apr 7, 2020 at 1:58 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-04-07 02:55, Veesh Goldman wrote:
> > Your question is way to vague. What do you actually want to do? If you
> > just wanna download a page, use curl or some other tool, no reason to do
> > it from raku if there's nothing more than that.
> > If you want more than that, then please be more specific.
>
> Hi Veesh,
>
> Sorry for the confusion.  I only wanted a small
> piece of a puzzle I am putting together.
>
> This big picture is this.
>
> I have a customer that runs RDP (Remote Desktop Protocol)
> server on Window 7.  He logs into this server with
> a Window 10 Pro laptop from all around the country using
> mstsc.exe and WFreeRDP.
>
> His new Internet provider at this house will use
> dynamic (floating) WAN (Wide Area Network) IP's.
>
> And he uses DropBox.  So I am writing a raku program
> on his RDP server to upload his WAN IP to Dropbox
> once an hour and another program on his RDP client
> to read the drop box file and wrap mstsc and WFree
> RDP with his server's WAN address.
>
> That is also why I asked the DropBox question.
> (DropBox works marvelously on Fedora 31).  But
> Since Drop Box and Cobian Backup on Windows
> don't mesh, I am being extra careful. (I think
> the issue is Cobain's use of Volume Shadow
> Copy Service.)
>
> -T
>


Can a sub be released?

2020-04-07 Thread ToddAndMargo via perl6-users

Hi All,

Can a subroutine be released from the main program
to go off on its own?  (Is this called "forked"?)

If not how do I do a `qqx` or a `run` that releases
the program to go off on its own?

Many thanks,
-T


sleep 3600 vs task scheduler

2020-04-07 Thread ToddAndMargo via perl6-users

Hi All,

Windows 7/10

Another piece of the puzzle.

I want to loop Raku program once an hour.

Is it better use `sleep 3600` or let the program
die and restart every hour from the Task Scheduler.
By better, I mean less of a CPU footprint.

`sleep` would allow the user to cancel the program
and not have it come back.

Many thanks,
-T


Re: How to read a web page?

2020-04-07 Thread ToddAndMargo via perl6-users

On 2020-04-07 02:55, Veesh Goldman wrote:
Your question is way to vague. What do you actually want to do? If you 
just wanna download a page, use curl or some other tool, no reason to do 
it from raku if there's nothing more than that.

If you want more than that, then please be more specific.


Hi Veesh,

Sorry for the confusion.  I only wanted a small
piece of a puzzle I am putting together.

This big picture is this.

I have a customer that runs RDP (Remote Desktop Protocol)
server on Window 7.  He logs into this server with
a Window 10 Pro laptop from all around the country using
mstsc.exe and WFreeRDP.

His new Internet provider at this house will use
dynamic (floating) WAN (Wide Area Network) IP's.

And he uses DropBox.  So I am writing a raku program
on his RDP server to upload his WAN IP to Dropbox
once an hour and another program on his RDP client
to read the drop box file and wrap mstsc and WFree
RDP with his server's WAN address.

That is also why I asked the DropBox question.
(DropBox works marvelously on Fedora 31).  But
Since Drop Box and Cobian Backup on Windows
don't mesh, I am being extra careful. (I think
the issue is Cobain's use of Volume Shadow
Copy Service.)

-T


Re: How to read a web page?

2020-04-07 Thread ToddAndMargo via perl6-users

On 2020-04-07 02:38, Shlomi Fish wrote:

Hi Todd!

On Tue, 7 Apr 2020 02:15:13 -0700
ToddAndMargo via perl6-users  wrote:


How do I read (download) a web page?  get?


See https://github.com/raku-community-modules/raku-lwp-simple and
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#how-can-i-write-code-to-perform-operations-on-web-sites-for-me-that-otherwise-should-be-done-manually
.

Note that there are many file types and formats that can be found on the WWW
and downloaded using HTTP/HTTPS.


Thank you!  I figured it out.


Re: How to read a web page?

2020-04-07 Thread Shlomi Fish
Hi Todd!

On Tue, 7 Apr 2020 02:15:13 -0700
ToddAndMargo via perl6-users  wrote:

> How do I read (download) a web page?  get?

See https://github.com/raku-community-modules/raku-lwp-simple and
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#how-can-i-write-code-to-perform-operations-on-web-sites-for-me-that-otherwise-should-be-done-manually
.

Note that there are many file types and formats that can be found on the WWW
and downloaded using HTTP/HTTPS.



-- 

Shlomi Fish   https://www.shlomifish.org/
NSA Factoids - https://www.shlomifish.org/humour/bits/facts/NSA/

Barth's Distinction:  There are two types of people: those who divide people
into two types, and those who don't.
— via fortune-mod.

Please reply to list if it's a mailing list post - https://shlom.in/reply .


Re: How to read a web page?

2020-04-07 Thread ToddAndMargo via perl6-users

> On Tue, Apr 7, 2020 at 12:15 PM ToddAndMargo via perl6-users
> mailto:perl6-users@perl.org>> wrote:
>
> How do I read (download) a web page?  get?

On 2020-04-07 02:55, Veesh Goldman wrote:
Your question is way to vague. What do you actually want to do? If you 
just wanna download a page, use curl or some other tool, no reason to do 
it from raku if there's nothing more than that.

If you want more than that, then please be more specific.


Hi Veesh,

My question sounded vague as it was meant to be simple.
I wanted to give a url and get back the HTML of the url.

As far as curl goes, I wrote a module that
interfaces with curl.  It would do this perfectly,
except I wanted something very simple in this instance:
a pea shooter instead of a howitzer (my curl module).


$ raku -e 'use HTTP::Client; my $client=HTTP::Client.new;
 my $response =  $client.get("http://checkip.dyndns.org/;);
 say $response.content;
 (my $x=$response.content) ~~ s/.*? "Address: "//;
 $x~~s/\< .* //;
 say "WAN IP Address is " ~ $x;'

 Current IP CheckCurrent IP 
Address: 50.37.24.122


 WAN IP Address is 50.37.24.122

Now is there were nasty redirects to follow or cookie or
referrers or headers to input, yada, yada yada, my curl
module would work perfect.  I just wanted something simple
this time.

-T


Re: How to read a web page?

2020-04-07 Thread ToddAndMargo via perl6-users

On 2020-04-07 02:15, ToddAndMargo via perl6-users wrote:

How do I read (download) a web page?  get?


Came up with this:

  # zef --force-test install HTTP::Client

  $ raku -e 'use HTTP::Client; my $client=HTTP::Client.new; my 
$response = $client.get("http://checkip.dyndns.org/;); say 
$response.content;'


   Current IP CheckCurrent IP 
Address: 50.37.24.122


Re: How to read a web page?

2020-04-07 Thread Veesh Goldman
Your question is way to vague. What do you actually want to do? If you just
wanna download a page, use curl or some other tool, no reason to do it from
raku if there's nothing more than that.
If you want more than that, then please be more specific.

On Tue, Apr 7, 2020 at 12:15 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> How do I read (download) a web page?  get?
>


How to read a web page?

2020-04-07 Thread ToddAndMargo via perl6-users

How do I read (download) a web page?  get?


Re: Dropbox and IO?

2020-04-07 Thread Simon Proctor
Ok I don't have access to my windows box until this evening. I'm mostly
used to using Dropbox on a Linux box where it's just a folder.

Sorry for my mistake.

On Tue, 7 Apr 2020 at 07:51, Shlomi Fish  wrote:

> Hi Simon,
>
> On Tue, 7 Apr 2020 06:55:00 +0100
> Simon Proctor  wrote:
>
> > Don't see why not, Dropbox is just a folder that you should be able to
> > access as normal.
> >
>
> Is it a higher-level folder or a bona-fide filesystem direcory:
>
> https://en.wikipedia.org/wiki/Directory_(computing)#Folder_metaphor
>
> If it is not visible to the filesystem, one may need higher level APIs
> other
> than fopen ( https://en.cppreference.com/w/c/io/fopen ) and friends.
>
> > On Tue, 7 Apr 2020, 02:22 ToddAndMargo via perl6-users, <
> > perl6-users@perl.org> wrote:
> >
> > > Hi All,
> > >
> > > Do any of you using Windows and Dropbox know
> > > if Raku's file IO utilities can both read
> > > and write to a Drop Box drive?
> > >
> > > Many thanks,
> > > -T
> > >
>
>
>
> --
>
> Shlomi Fish   https://www.shlomifish.org/
> https://www.shlomifish.org/open-source/resources/tech-tips/
>
> How many “one-liners” do I actually write? I don’t know; maybe a couple
> dozen
> a day. But I guess I must be unusual, because as we all know, AWK was a
> complete failure and vanished into obscurity since it didn’t address
> anyone’s
> real needs. (That was sarcasm.) — “Twelve Views of Mark Jason Dominus”
>
> Please reply to list if it's a mailing list post - https://shlom.in/reply
> .
>


-- 
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/


Re: Dropbox and IO?

2020-04-07 Thread Shlomi Fish
Hi Simon,

On Tue, 7 Apr 2020 06:55:00 +0100
Simon Proctor  wrote:

> Don't see why not, Dropbox is just a folder that you should be able to
> access as normal.
> 

Is it a higher-level folder or a bona-fide filesystem direcory:

https://en.wikipedia.org/wiki/Directory_(computing)#Folder_metaphor

If it is not visible to the filesystem, one may need higher level APIs other
than fopen ( https://en.cppreference.com/w/c/io/fopen ) and friends.

> On Tue, 7 Apr 2020, 02:22 ToddAndMargo via perl6-users, <
> perl6-users@perl.org> wrote:
> 
> > Hi All,
> >
> > Do any of you using Windows and Dropbox know
> > if Raku's file IO utilities can both read
> > and write to a Drop Box drive?
> >
> > Many thanks,
> > -T
> >  



-- 

Shlomi Fish   https://www.shlomifish.org/
https://www.shlomifish.org/open-source/resources/tech-tips/

How many “one-liners” do I actually write? I don’t know; maybe a couple dozen
a day. But I guess I must be unusual, because as we all know, AWK was a
complete failure and vanished into obscurity since it didn’t address anyone’s
real needs. (That was sarcasm.) — “Twelve Views of Mark Jason Dominus”

Please reply to list if it's a mailing list post - https://shlom.in/reply .