Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: CPAN 2.29 stuck with Net::SSLeay (updated)

by haukex (Archbishop)
on Mar 14, 2022 at 07:32 UTC ( [id://11142081]=note: print w/replies, xml ) Need Help??


in reply to Re^2: CPAN 2.29 stuck with Net::SSLeay
in thread CPAN 2.29 stuck with Net::SSLeahy

I'm not quite sure what you mean with reference to the "system package manager." I find no GUI equivalent of Ubuntu's "synaptic package manager." I prefer to get things done on the command line with *nix. ... I wonder if you mean something like dpkg. ... sudo apt-get install libnet-ssleay-perl ... Would this be an instance of using the "system package manager," as you mean it?

The system package manager is the Advanced Package Tool on Debian-based systems like Ubuntu and Raspbian, and the RPM Package Manager on RedHat-based systems. Synaptic is just a frontend for APT and dpkg is one of the lower-level tools used by APT. Using APT from the commandline is done with the apt* commands, so yes, the apt-get command is what I meant. I personally often use the aptitude frontend for package management from the command line.

I do have a sticky wicket, where I can't get cpanm to find dependencies: ... Configuring . failed. See /home/pi/.cpanm/work/1647208802.16932/build.log for details.

You'd have to look into that file for the actual error message and let us know what it is. I might suspect a missing dependency on a lower level than Perl modules, e.g. a C library.

I herded the requires into a barebones module in its own directory. I don't know how to serve it up any better than that.(?)

Your requires1.pm would typically be called cpanfile and not start with a package statement. See cpanfile and the corresponding discussion in your thread Using Cartons to automate module installs.

I couldn't get cpanm to find modules in typical perl .pl scripts

You might be interested in lazy, though as the name implies, this shouldn't be your package management solution of choice.

Regarding section 5, Crontab to broadcast RPi's address and name, What is the purpose of doing this? Would this cause you to be indexed by search engines, or is it all within 50 yards

UDP broadcasts are usually not forwarded by routers, especially not to the Internet, so this should stay within the local network. On some (nowadays many) local networks, the router is smart enough to add a local DNS entry so the RPi can be reached by its hostname. On other networks, this may not be available, so there, this UDP broadcast simply serves for me to discover the IP that the RPi has been assigned. I broadcast the hostname so that I can keep multiple RPi apart (which is why it's a good idea to change the default hostname).

Update: The background for this is that I prefer a headless setup of my RPis, purely over the network, which is why my notes include instructions on how to enable WiFi and the ssh server. There is a small security risk in not changing the password from the default before the first boot, perhaps I will update my notes in that regard. Update 2: Done. Also, BitBucket wasn't rendering some of the Markdown correctly, which should now be fixed, so those crontab lines you quoted should be readable on the site now (when in doubt, refer to the source). /Update

Can you break this up into parts

I'm basicially just sending the hostname in a UDP broadcast packet, where the socat commandline is what I looked up for that purpose, I'm not an socat expert :-) The crontab entries cause that to happen every minute, plus one extra time at boot, and I do 2>/dev/null so I don't get tons of emails from the cron daemon.

Replies are listed 'Best First'.
Re^4: CPAN 2.29 stuck with Net::SSLeay (updated)
by Aldebaran (Curate) on Apr 21, 2022 at 01:18 UTC
    UDP broadcasts are usually not forwarded by routers, especially not to the Internet, so this should stay within the local network. On some (nowadays many) local networks, the router is smart enough to add a local DNS entry so the RPi can be reached by its hostname. On other networks, this may not be available, so there, this UDP broadcast simply serves for me to discover the IP that the RPi has been assigned.

    I see. I've been trying to figure out everything that's going on with your udplisten.pl. I've made some changes primarily to introduce time measurement in a way that I could use for the higher-level abstractions of DateTime. Also, I couldn't understand where the newline after mypi was coming in, but I think that's what Data::Dumper gives the string in dumpstr. Regarding this syntax:

    my $FULLMSG = !!$opts{m};

    I searched for an operator !! in perlop, and not finding it have to believe it's a double application of !, essentially "Not-not". It seems to have the effect of making LHS the same as RHS, whether RHS is defined or not. That was torturous to say; do I have it right?

    Update: The background for this is that I prefer a headless setup of my RPis, purely over the network, which is why my notes include instructions on how to enable WiFi and the ssh server. There is a small security risk in not changing the password from the default before the first boot, perhaps I will update my notes in that regard. Update 2: Done. Also, BitBucket wasn't rendering some of the Markdown correctly, which should now be fixed, so those crontab lines you quoted should be readable on the site now (when in doubt, refer to the source). /Update

    The revision in Markdown did help me make an effective crontab command with this as the result:

    $ crontab -l # Edit this file to introduce tasks to be run by cron. ... # m h dom mon dow command */17 * * * * hostname | socat -s - UDP-DATAGRAM:255.255.255.255:12340 +,broadcast 2>/dev/null $

    Source:

    #!/usr/bin/env perl use warnings; use strict; use 5.010; no feature 'switch'; =head1 SYNOPSIS Waits for message(s) on a UDP port and when a message is received, prints the IP address from which each message was received. udplisten.pl [-m] [-c COUNT] [-a] [-p PORT] [-e EXPR] [-b RXSZ] OPTIONS: -m - Output the entire message, not just the IP address -c COUNT - Exit after receiving this many messages (default=1) -a - Continuously output all messages (overrides -c) -p PORT - UDP port number (default=12340) -e EXPR - Output only messages which match this Perl expression -b RXSZ - Receive length (default=1024) =head1 DETAILS The message can be transmitted, for example, via the following L<crontab(5)> entry (note: C<sudo apt-get install socat>): * * * * * echo "HELLO xyZ129" | socat - UDP-DATAGRAM:255.255.255.255 +:12340,broadcast The string used can be completely random; the idea is for it to be uni +que to your device so you can identify it, for example: udplisten.pl -e '/HELLO xyZ129/' Two alternate ways to listen are via L<netcat(1)> or L<socat(1)> (note these will receive and print I<any> messages on that port): netcat -ul 12340 # may need to use -p12340 instead socat -u udp-recv:12340 - Don't forget to open the port for incoming UDP traffic on your local f +irewall, for example for L<UFW|https://wiki.ubuntu.com/UncomplicatedFirewall>: ufw allow in 12340/udp B<Note> that the choice of port number above is completely random. At the time of writing, this port appears to be unused (L<http://www.iana.org/assignments/port-numbers>), but if you've got other things on your network that use this port, cho +ose a different one. You're also free to, for example, use different ports for different de +vices. =head1 AUTHOR, COPYRIGHT, AND LICENSE Copyright (c) 2016 Hauke Daempfling (haukex@zero-g.net) at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (I +GB), Berlin, Germany, L<http://www.igb-berlin.de/> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see L<http://www.gnu.org/licenses/>. =cut use Getopt::Std 'getopts'; use Pod::Usage 'pod2usage'; use IO::Socket::INET (); use Data::Dumper; use DateTime; use DateTime::Format::Duration; sub HELP_MESSAGE { pod2usage( -output => shift ); return } sub VERSION_MESSAGE { say {shift} q$udplisten.pl v2.00$; return } $Getopt::Std::STANDARD_HELP_VERSION = 1; getopts( 'mc:ap:e:b:', \my %opts ) or pod2usage; my $FULLMSG = !!$opts{m}; my $COUNT = $opts{c} // 1; pod2usage("Bad count") unless $COUNT && $COUNT =~ /^\d+$/ && $COUNT > +0; my $ALLMSGS = !!$opts{a}; my $PORT = $opts{p} // 12340; pod2usage("Bad port") unless $PORT && $PORT =~ /^\d+$/ && $PORT > 0; my $EXPR = $opts{e}; my $RXSZ = $opts{b} // 1024; pod2usage("Bad receive length") unless $RXSZ && $RXSZ =~ /^\d+$/ && $R +XSZ > 0; pod2usage("Extra arguments") if @ARGV; my $sock = IO::Socket::INET->new( LocalPort => $PORT, Proto => 'udp', ) or die "error in socket creation: $!"; my $count = 0; my $dt; my $start = DateTime->now; say "Start time is: ", $start->hms; my $later; RXLOOP: while (1) { defined $sock->recv( my $rx, $RXSZ ) or die "error during recv: $!"; my $peeraddr = $sock->peerhost; my $match = 1; if ( defined $EXPR ) { local $_ = $rx; eval "\$match = do { package CodeEval; $EXPR }; 1" or die "Perl expression failed: " . ( $@ || "Unknown error" ); } next RXLOOP unless $match; say "rx is $rx"; say $FULLMSG ? "From $peeraddr: " . dumpstr($rx) : "$peeraddr"; $dt = DateTime->now; say "Time is: ", $dt->hms; $later = $dt; last RXLOOP if !$ALLMSGS && ++$count >= $COUNT; } $sock->close; my $d = DateTime::Format::Duration->new( pattern => '%Y years, %m months, %e days, ' . '%H hours, %M minutes, %S seconds' ); my $duration_object = $later - $start; say $d->format_duration($duration_object); sub dumpstr { chomp( my $s = Data::Dumper->new( [ '' . shift ] )->Terse(1)->Useqq(1)->Dump ); return $s; }

    Slightly-redacted output:

    $ ./2.udplisten.pl -m -c 2 Start time is: 23:30:43 rx is mypi From 192.168.red.acted: "mypi\n" Time is: 23:34:01 rx is mypi From 192.168.red.acted: "mypi\n" Time is: 23:51:01 0 years, 00 months, 0 days, 00 hours, 20 minutes, 18 seconds $

    so, everything's looking pretty good, but I wanted to complete step 4 in your rpi setup, with some attempt to understand it along the way:

    man rsyslog

    On my first attempt, I just tacked it on the end:

    # patch 4/20/2022 -*.*;auth,authpriv.none -/var/log/syslog +*.*;cron,auth,authpriv.none -/var/log/syslog

    , and restarted:

     sudo systemctl restart rsyslog

    , but rsyslog did not want to parse these lines:

    Apr 20 16:41:59 mypi systemd[1]: Stopped System Logging Service. Apr 20 16:41:59 mypi systemd[1]: Starting System Logging Service... Apr 20 16:41:59 mypi rsyslogd: error during parsing file /etc/rsyslog. +conf, on or before line 94: errors occured in file '/etc/rsyslog.conf +' around line 94 [v8.1901.0 try https://www.rsyslog.com/e/2207 ] Apr 20 16:41:59 mypi rsyslogd: error during parsing file /etc/rsyslog. +conf, on or before line 95: invalid character '+' - is there an inval +id escape sequence somewhere? [v8.1901.0 try https://www.rsyslog.com/ +e/2207 ] Apr 20 16:41:59 mypi systemd[1]: Started System Logging Service.

    , so I recalled that I didn't see any notation for a leading + or -, and went with this instead in /etc/rsyslog.conf:

    ############### #### RULES #### ############### # # First some standard log files. Log by facility. # auth,authpriv.* /var/log/auth.log #*.*;auth,authpriv.none -/var/log/syslog *.*;cron,auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log lpr.* -/var/log/lpr.log mail.* -/var/log/mail.log user.* -/var/log/user.log

    , and that looks more like it, the parser having no objections. The man page for rsyslog had promised an html page, which I was enjoined to find. When running

     cat /var/log/syslog

    after a successful start, this url was posted as output: www.rsyslog.com, where I finally learned what the r is for in rsyslog. (rocket-fast)

    So, yay, at the pace of a tortoise I think I've got task 4 covered. Thank you for your comments.

    Gruss aus Amiland,

      I searched for an operator !! in perlop, and not finding it have to believe it's a double application of !, essentially "Not-not". It seems to have the effect of making LHS the same as RHS, whether RHS is defined or not. That was torturous to say; do I have it right?

      Almost, but not quite. It makes the LHS the truth of the RHS, not the value. See Bang bang in perlsecret - which is also the place to look for any other combination-operator idiomata you might happen upon.


      🦛

Re^4: cpanm stuck with Plack::Handler::Twiggy
by Aldebaran (Curate) on Apr 02, 2022 at 23:40 UTC
    Your requires1.pm would typically be called cpanfile and not start with a package statement. See cpanfile and the corresponding discussion in your thread Using Cartons to automate module installs.

    Yes, indeed...thank you for the reminder, both then and now. I find myself refering back to previous write-ups when I'm facing the issues of breaking in a new system. A person tries to do the same things, but they are all a bit different. I've been able to get everything loaded except Plack::Handler::Twiggy.

    cpan shows that my version is undef, both before and after I reinstall:

    $ cpan -l | grep Twiggy Twiggy 0.1026 Twiggy::Server undef Twiggy::Server::SS undef Plack::Handler::Twiggy undef

    I try to use cpanm to reinstall:

    $ cpanm --reinstall --verbose Plack::Handler::Twiggy cpanm (App::cpanminus) 1.7044 on perl 5.028001 built for arm-linux-gnu +eabihf-thread-multi-64int ... Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/ ... Entering Twiggy-0.1026 ... Configuring Twiggy-0.1026 ... Checking if your kit is complete... Looks good ... All tests successful. Result: PASS ... 1 distribution installed

    But the needle hasn't moved:

    $ cpan -l | grep Twiggy Twiggy 0.1026 Twiggy::Server undef Twiggy::Server::SS undef Plack::Handler::Twiggy undef $

    , and this consigns this command to failure:

    $ cpanm --verbose --installdeps . cpanm (App::cpanminus) 1.7044 on perl 5.028001 built for arm-linux-gnu +eabihf-thread-multi-64int ... Checking if you have Plack::Handler::Twiggy 0.1025 ... No ... Checking if you have GPS::NMEA 0.17 ... Yes (1.12) ==> Found dependencies: Plack::Handler::Twiggy Searching Plack::Handler::Twiggy (0.1025) on cpanmetadb ... Found Plack::Handler::Twiggy which doesn't satisfy 0.1025. ! Installing the dependencies failed: Installed version (undef) of Pla +ck::Handler::Twiggy is not in range '0.1025' ! Bailing out the installation for .. $

    So I'm still caught in the tentacles of Charybdis with this one module, looking for tips on how to get it installed properly. How do I get Plack::Handler::Twiggy to be version 0.1026 like Twiggy?

    Cheers,

      There is a difference between a distribution and the modules that it contains. If you look at the distribution Twiggy, you'll see it contains those modules, but if you look at the source of the modules, they don't define a $VERSION, which is allowed. Though personally I would try to give every module in a distribution the same version, when it comes to the installation, you don't need to worry about what version the individual modules of a distribution have - when defining dependencies, it's enough to define a dependency on the latest version of the module Twiggy to get all of the modules in its distribution installed.

        There is a difference between a distribution and the modules that it contains. If you look at the distribution Twiggy, you'll see it contains those modules, but if you look at the source of the modules, they don't define a $VERSION, which is allowed. Though personally I would try to give every module in a distribution the same version, when it comes to the installation, you don't need to worry about what version the individual modules of a distribution have - when defining dependencies, it's enough to define a dependency on the latest version of the module Twiggy to get all of the modules in its distribution installed.

        Ok, I did take a gander through Twiggy, and realized that

        requires 'Plack::Handler::Twiggy' => '0.1025';

        was never gonna be satified. I altered the cpanfile to this:

        #requires 'Plack::Handler::Twiggy' => '0.1025'; ## this module ^^ is sliced up differently requires 'AnyEvent::AIO' => '1.1'; requires 'Async::Interrupt' => '1.24'; requires 'Cookie::Baker::XS' => '0.09'; requires 'Device::Firmata' => '0.65'; requires 'Device::SerialPort' => '1.04'; requires 'Device::WebIO' => '0.022'; requires 'Device::WebIO::Dancer' => '0.004'; requires 'Device::WebIO::Firmata' => '0.002'; requires 'Device::WebIO::RaspberryPi' => '0.900'; requires 'DBD::SQLite' => '1.58'; requires 'DBI' => '1.641'; requires 'Guard' => '1.023'; requires 'GPS::NMEA' => '0.17'; requires 'Math::Round' => '0.07'; requires 'RPi::WiringPi' => '2.3628'; requires 'RPi::Pin' => '2.3606'; requires 'Plack::Handler::Twiggy' => 'undef'; requires 'Starman' => '0.4014'; requires 'Time::HiRes' => '1.9758'; requires 'Twiggy' => '0.1025'; requires 'WWW::Form::UrlEncoded::XS' => '0.25';

        , and got it the checks to pass:

        $ cpanm --verbose --installdeps . ... Checking if you have Plack::Handler::Twiggy 0 ... Yes (undef) ... Checking if you have Twiggy 0.1025 ... Yes (0.1026) ... $

        What's more, I looked ahead in stevieb's guide for source I might use, and I didn't see the module included in stuff that I was going to use anytime soon. I was super-pleased to have his guide to orient me through installing the camera:

        The one downside of the CSI-2 connector is that it’s attached with a ribbon cable, which can be a bit flimsy. The connector sits by the HDMI port on most Pis. This shouldn’t be confused with the DSI (Display Serial Interface) connector, which sits near the SD card. ... Power off your Pi, and then insert the cable. You’ll see a small strip of tape along one edge of the ribbon cable. On most Pi’s, this will face the edge with the Ethernet and USB ports.

        I was almost despondent when I saw that ribbon. Getting that in the right place the right way the first time was faith-promoting.

        $ raspistill -o 1.test_pic.jpg $ ls 1.test_pic.jpg

        A clear and sharp photo results, flimsy ribbon notwithstanding....

      Disturbing lack of paths in your verbosity
        Disturbing lack of sense in your post

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11142081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found