perl using .Net with WinSCP and ListDirectory parameter per File 'FilePermissions'
Hello,
Wanting to understand how the file permissions might be being returned, using Perl and the .Net WinSCP "ListDirectory" functionality.
I followed the examples for both Perl, and for PowerShell, and see how in PowerShell, after reading in the list of files from a remote SFTP site, this print (WriteHost) statement gives straight information I'm coveting in my Perl script:
foreach ($fileInfo in $directory.Files)
{
Write-Host ("$($fileInfo.Name) with size $($fileInfo.Length), " +
"permissions $($fileInfo.FilePermissions) and " +
"last modification at $($fileInfo.LastWriteTime)")
}
Following the same logic, and parameters given, I can duplicate this with Perl, , using Win32::OLE .Net WinSCP method:
my $directory = $session->ListDirectory("/files/");
my $items = Win32::OLE::Enum->new($directory->{'Files'});
However, specifically, the value inside the loop of file objects for FilePermissions:
my $item;
while (defined($item = $items->Next))
for: $item->{'FilePermissions'}
Produces the following sort of output:
FilePermissions = <Win32::OLE=HASH(0x25cc0e0)>
FilePermissions = <Win32::OLE=HASH(0x25cc0f8)>
.
.
.
The same files, in the PowerShell output give:
FilePermissions = <rw-rw-r-->
FilePermissions = <rw-rw-r-->
I tried setting the value returned by 'FilePermissions' to a Hash, and palying around with, but having no luck getting the proper output (And am modifying a program that's written in Perl, so can't really simply go to PowerShell for all of it at this time).
Thank you,
Joe P.
Wanting to understand how the file permissions might be being returned, using Perl and the .Net WinSCP "ListDirectory" functionality.
I followed the examples for both Perl, and for PowerShell, and see how in PowerShell, after reading in the list of files from a remote SFTP site, this print (WriteHost) statement gives straight information I'm coveting in my Perl script:
foreach ($fileInfo in $directory.Files)
{
Write-Host ("$($fileInfo.Name) with size $($fileInfo.Length), " +
"permissions $($fileInfo.FilePermissions) and " +
"last modification at $($fileInfo.LastWriteTime)")
}
Following the same logic, and parameters given, I can duplicate this with Perl, , using Win32::OLE .Net WinSCP method:
my $directory = $session->ListDirectory("/files/");
my $items = Win32::OLE::Enum->new($directory->{'Files'});
However, specifically, the value inside the loop of file objects for FilePermissions:
my $item;
while (defined($item = $items->Next))
for: $item->{'FilePermissions'}
Produces the following sort of output:
FilePermissions = <Win32::OLE=HASH(0x25cc0e0)>
FilePermissions = <Win32::OLE=HASH(0x25cc0f8)>
.
.
.
The same files, in the PowerShell output give:
FilePermissions = <rw-rw-r-->
FilePermissions = <rw-rw-r-->
I tried setting the value returned by 'FilePermissions' to a Hash, and palying around with, but having no luck getting the proper output (And am modifying a program that's written in Perl, so can't really simply go to PowerShell for all of it at this time).
Thank you,
Joe P.