Re: I need help with .IO.d.Bool

2025-04-06 Thread ToddAndMargo via perl6-users

On 4/5/25 6:58 PM, ToddAndMargo via perl6-users wrote:

sub Directory


I changed the name to DirectoryExists

The new name is more human friendly


Re: I need help with .IO.d.Bool

2025-04-05 Thread ToddAndMargo via perl6-users

On 4/2/25 6:08 PM, Bruce Gray wrote:




On Apr 2, 2025, at 19:47, ToddAndMargo via perl6-users  
wrote:


--snip--


   raku -e "say 
'\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1'.IO.d.Bool;"
   False


--snip--

Moving this one-liner into a .raku file (to remove the complication of Windows 
needing double-quotes for our `-e`), and removing `.IO.d.Bool`, I ran just this 
line:
say '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1';
The output is:
\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1
So, the initial two backslashes are becoming a single backslash.
You need a quoting that does not special-case doubled backslashes (like the Q[] 
I have seen you use), or to enter the path with initial quadruple backslashes.

Does changing your one-liner to this:
raku -e "say 
Q[\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1].IO.d.Bool;"
fix the problem?
If not, remove the `.Bool` just for a test run. You might still get False (like 
if the path exists but is not a directory), or you might get a Exception that 
gives you more detail of what is going wrong (like `Failed to find ...`, with 
the exact path that it was *actually* looking for).




Hi Bruce,

I need the function to operate with the exact path
assigned by Windows.  No adding or subtracting.

This was my work around:


sub Directory( Str $DriveDirectory ) returns Bool is export( :Directory )  {
   # True if a Directory or Drive Letter

   my Str $RtnStr   = RunCmd( "powershell.exe test-path  -Path " ~ Q["] 
~ $DriveDirectory ~ Q["] ~ " -PathType Container", True );

   # print "RtnStr = <$RtnStr>\n";
   if $RtnStr.lc.starts-with( "true" )  { return True; } else { return 
False; }

}


Notice that I did not have to mess the `$DriveDirectory`?

.IO.d.Bool needs to do the same.

Let me know if you want the code for `RunCmd`.

Thank you for the help,
-T




Re: I need help with .IO.d.Bool

2025-04-05 Thread Bruce Gray



> On Apr 2, 2025, at 19:47, ToddAndMargo via perl6-users  
> wrote:

--snip--

>   raku -e "say 
> '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1'.IO.d.Bool;"
>   False

--snip--

Moving this one-liner into a .raku file (to remove the complication of Windows 
needing double-quotes for our `-e`), and removing `.IO.d.Bool`, I ran just this 
line:
say '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1';
The output is:
\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1
So, the initial two backslashes are becoming a single backslash.
You need a quoting that does not special-case doubled backslashes (like the Q[] 
I have seen you use), or to enter the path with initial quadruple backslashes. 

Does changing your one-liner to this:
raku -e "say 
Q[\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1].IO.d.Bool;"
fix the problem?
If not, remove the `.Bool` just for a test run. You might still get False (like 
if the path exists but is not a directory), or you might get a Exception that 
gives you more detail of what is going wrong (like `Failed to find ...`, with 
the exact path that it was *actually* looking for).

-- 
Hope this helps,
Bruce Gray (Util of PerlMonks)



Re: I need help with .IO.d.Bool

2025-04-04 Thread ToddAndMargo via perl6-users

On 4/2/25 9:53 PM, ToddAndMargo via perl6-users wrote:

On 4/2/25 6:26 PM, Will Coleda wrote:

Try printing the Str before you do anything with it to see what happens.



I moved to powershell


I mean I did a call to powershell to find if a directory existed


Re: I need help with .IO.d.Bool

2025-04-02 Thread ToddAndMargo via perl6-users

On 4/2/25 6:26 PM, Will Coleda wrote:

Try printing the Str before you do anything with it to see what happens.



I moved to powershell


Re: I need help with .IO.d.Bool

2025-04-02 Thread ToddAndMargo via perl6-users

On 4/2/25 6:08 PM, Bruce Gray wrote:




On Apr 2, 2025, at 19:47, ToddAndMargo via perl6-users  
wrote:


--snip--


   raku -e "say 
'\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1'.IO.d.Bool;"
   False


--snip--

Moving this one-liner into a .raku file (to remove the complication of Windows 
needing double-quotes for our `-e`), and removing `.IO.d.Bool`, I ran just this 
line:
say '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1';
The output is:
\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1
So, the initial two backslashes are becoming a single backslash.
You need a quoting that does not special-case doubled backslashes (like the Q[] 
I have seen you use), or to enter the path with initial quadruple backslashes.

Does changing your one-liner to this:
raku -e "say 
Q[\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1].IO.d.Bool;"

> fix the problem?

Yes.

raku -e "say 
Q[\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1].IO.d.Bool;"

True

raku -e "say 
Q[\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup10].IO.d.Bool;"

False

Now how do I encode a variable inside a Q[]?




If not, remove the `.Bool` just for a test run. You might still get False (like 
if the path exists but is not a directory), or you might get a Exception that 
gives you more detail of what is going wrong (like `Failed to find ...`, with 
the exact path that it was *actually* looking for).





Re: I need help with .IO.d.Bool

2025-04-02 Thread Will Coleda
Try printing the Str before you do anything with it to see what happens.

(Hint - the backslash character escapes characters in literal strings)

On Wed, Apr 2, 2025 at 8:47 PM ToddAndMargo via perl6-users <
[email protected]> wrote:

> Hi All,
>
> Windows Server 2025 (souped up W11)
>
> raku -v
> Welcome to RakudoΓäó v2025.02.
>
> I am trying to see if this directory exists:
>  \\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1
>
> This is what raku .IO.d.Bool give me:
> raku -e "say
> '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1'.IO.d.Bool;"
> False
>
> But power shell says it does me:
>  powershell Test-Path
> \\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1
>  True
>
>  From \\192.168.240.10, (a Samba server), it also tells me the
> directory indeed does exist:
>
> # ls -al /mnt/LinuxServer/Backup/MyDocsBackup
> total 36
> drwxrwsrwx. 5 public root 4096 Mar 31 18:37 .
> drwxrwsrwx. 5 root   root 4096 Mar 19 17:16 ..
> drwxrwsrwx. 4 public root 4096 Mar 31 18:37 backup1
> drwxrwsrwx. 4 public root 4096 Mar 31 17:57 backup2
> drwxrwsrwx. 4 public root 4096 Mar 31 17:47 backup3
>
>
> What am I doing wrong?
>
> Many thanks,
> -T
>
>
>