Re: Adding Perl modules?
On 07/12/2021 06:39, David Taylor wrote: Here is the script I'm trying to run. It analyses two directories for their total size and returns an output in a format suitable for MRTG. Perhaps I should just substitute Win64 for Win32? I've only used Win32 before. Folks, Many thanks for the suggestions. I adopted the easy way out. As the Win32 bit was only required for the GetTickCount, and as GetTickCount was used to derived the uptime, and as uptime was not an essential part of the program's output, I simply removed the unnecessary code and output a "0" instead which MRTG chooses to ignore. I've left Get_iplayer alone so that any future installs should not be affected. New release just installed, but not yet tested. Cheers, David -- SatSignal Software - Quality software for you Web: https://www.satsignal.eu Email: david-tay...@blueyonder.co.uk Twitter: @gm8arv ___ get_iplayer mailing list get_iplayer@lists.infradead.org http://lists.infradead.org/mailman/listinfo/get_iplayer
Re: Adding Perl modules?
On 07/12/2021 06:39, David Taylor wrote: I would like to add the Win32::API to the Perl which comes with get_iplayer. Is that possible? Surely, on a Windows machine, all the necessary Win32::* should be installed already? What does the following command sequence give for you, my output is as below: >cpan cpan> m Win32::API Module id = Win32::API CPAN_USERID BULKDD (Daniel Dragan ) CPAN_VERSION 0.84 CPAN_FILEB/BU/BULKDD/Win32/Win32-API-0.84.tar.gz MANPAGE Win32::API - Perl Win32 API Import Facility INST_FILEC:\Programs\Perl\lib\Win32\API.pm INST_VERSION 0.84 cpan> q Lockfile removed. More generally, if you want to see all the modules beginning with 'win32', you can substitute the following for the cpan command: cpan> m /^win32.*/ Here is the script I'm trying to run. It analyses two directories for their total size and returns an output in a format suitable for MRTG. Perhaps I should just substitute Win64 for Win32? I've only used Win32 before. Here's the script in case it clarifies things... ~ # From: http://www.perlmonks.org/?node_id=2311 # and: https://rt.cpan.org/Public/Bug/Display.html?id=61520 # Note that Windows Vista/Server 2008 or later is required for GetTickCount64. # This version returns bytes, not MB. use strict; use Win32::API; use Sys::Hostname; my $GetTickCount; $GetTickCount = Win32::API->new("kernel32", "int GetTickCount64()"); my $uptime; my $dir1 = '.'; my $dir2 = '.'; if (@ARGV[0] ne "") { $dir1 = @ARGV[0]; } if (@ARGV[1] ne "") { $dir2 = @ARGV[1]; } print _tree_size($dir1) . "\n"; print _tree_size($dir2) . "\n"; $uptime = $GetTickCount->Call() / 1000; printf "%d day(s) %dh %dm\n", int($uptime/86400), int(($uptime/3600)%24), int(($uptime%3600)/60); print "PC " . hostname . "\n"; exit 0; sub dir_tree_size { my $dir = shift; my ($i,$total, $f); $total = 0; opendir DIR, $dir; my @files = grep !/^\.\.?$/, readdir DIR; for $i (@files) { $f = "$dir/$i"; if(-d $f) { $total += dir_tree_size($f) } else { $total += -s $f} } return $total; } ~ Although I've written one quite complicated script in Perl, to call GetIPlayer as it happens, I don't program in it often enough to class myself as expert enough to help with the above, but perhaps this helps, it shells out to DOS: https://bytes.com/topic/perl/answers/852485-directory-size-windows-activeperl ___ get_iplayer mailing list get_iplayer@lists.infradead.org http://lists.infradead.org/mailman/listinfo/get_iplayer
Re: Adding Perl modules?
On 2021-12-07 06:39, David Taylor wrote: I would like to add the Win32::API to the Perl which comes with get_iplayer. Is that possible? I don't know. When I used get_iplayer I chose not to use its installer, but to install my own distribution of perl and then the extra modules it needed, so as to be "in charge" of perl on my own machine. Otherwise if I'd wanted to use perl for anything else I'd have needed to have "my perl" and the g_ip one separately installed (so that the latter could be changed when g_ip needed it, without impacting on my own one). After doing the perl install and checking it had worked, which I did by issuing perl -h from a normal windows command window, which produced sensible output, I then did cpan App::cpanminus which uses the "cpan" command to get a module from http://www.cpan.org/ (the Comprehensive Perl Archive Network). I'd read somewhere that "cpanminus" is a wrapper for cpan which makes "cpan" easier to use, but clearly had to use "cpan" to get that. Issuing such a command basically attempts to fech, install and test a module. For me, with perl installed at a system level for every user, with eg perl binary folders placed on PATH, this worked. It might be trickier if the g_ip version of perl isn't pathed. Perhaps you can run the equivalent commands by CD into one of the perl directories and then run commands from there? I then issued cpanm commands for every module I knew I used (IIRC there was a list of them in the g_ip install notes for people not using the installers). So for example: C:\>cpanm Authen::SASL Authen::SASL is up to date. (2.16) would show me that an attempt to install the most recent version of Authen::SASL was unneeded because I already had it, whereas an earlier attempt (on a different machine) C:\>cpanm Authen::SASL --> Working on Authen::SASL Fetching http://www.cpan.org/authors/id/G/GB/GBARR/Authen-SASL-2.16.tar.gz ... FAIL ! Download http://www.cpan.org/authors/id/G/GB/GBARR/Authen-SASL-2.16.tar.gz failed. Retrying . .. ! Download http://www.cpan.org/authors/id/G/GB/GBARR/Authen-SASL-2.16.tar.gz failed. Retrying . .. ! Download http://www.cpan.org/authors/id/G/GB/GBARR/Authen-SASL-2.16.tar.gz failed. Retrying . .. ! Failed to download http://www.cpan.org/authors/id/G/GB/GBARR/Authen-SASL-2.16.tar.gz ! Failed to fetch distribution Authen-SASL-2.16 C:\> For that one, I've no idea why the download failed, but I subsequently grabbed the file with a browser then used C:\>cpanm "C:\Documents and Settings\XXX\My Documents\Downloads\Authen-SASL-2.16.tar.gz" --> Working on C:\Documents and Settings\XXX\My Documents\Downloads\Authen-SASL-2.16.tar.gz Fetching file://C:/Documents and Settings/XXX/My Documents/Downloads/Authen-SASL-2.16.tar.g z ... OK Configuring Authen-SASL-2.16 ... OK Building and testing Authen-SASL-2.16 ... OK Successfully installed Authen-SASL-2.16 1 distribution installed C:\> I don't know if that's helpful. -- Jeremy Nicoll - my opinions are my own ___ get_iplayer mailing list get_iplayer@lists.infradead.org http://lists.infradead.org/mailman/listinfo/get_iplayer