I'm eager to get 2022 off my machine and stowed away for the next year I have to deal with email and google, and I'm hoping it's not 2023. I think I have largely achieved de-google-isation of my scripts. I have a variety of smallish utility scripts that I wrote on uphill side of the learning curve of re-hosting with gitlab that I would like to wrap with perl. I've kicked the can forward on a number of fronts with approximating geological problems with highway data, where we were getting pretty deep in the weeds of a changing context. I don't have a map yet, but I've got a better idea what the hosting requirements will need to be. I have a grab-bag of semi-related issues, the common thread being that I want to do it in perl.

ephemeris

Q1) Are these points on the same meridian as my eyeball suggests? What is the best-fit "line?"

Q2) From these data, can we make any arguments about "betweenness?" This was such a beautful display first with the crescent moon, venus, then Jupiter, while Aldebaran tends the sheep and guards the Sisters. (I find some sky myths "believable" if they don't involve zombie carpenters.)

fritz@laptop:~/Documents$ ./1.2023.pl ./1.2023.pl Name Right Ascension Declination Jupiter 0.179353375287228 0.0559955210059931 Venus 0.0955771968036561 0.0254452716279536 Moon 0.655478796651881 0.262724424143006 Aldeb 1.20392811802569 0.288139315093836 Time is Fri Feb 24 20:32:39 2023 Julian day is 2460000.64767361 fritz@laptop:~/Documents$

Edit: removed 2 lines of unuseful source.

Source:

#!/usr/bin/perl use Time::Piece; use Astro::Coord::ECI::Utils 'deg2rad'; use Astro::Coords; my $log_conf4 = '/home/fritz/Documents/perlmonks/conf_files/3.conf'; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); $logger->info("Name\tRight Ascension\t\tDeclination"); for my $name (qw/Jupiter Venus Moon/) { my $planet2 = Astro::Coords->new( planet => $name ); $planet2->datetime( Time::Piece->new ); my $ra = $planet2->ra( format => q/rad/ ); my $dec = $planet2->dec( format => q/rad/ ); $logger->info("$name\t$ra\t$dec"); } my $aldeb_ra_degrees = 68.98; my $aldeb_ra_radians = deg2rad($aldeb_ra_degrees); my $aldeb_declination_degrees = 16.509166666667; my $aldeb_dec_radians = deg2rad($aldeb_declination_degrees); $logger->info("Aldeb\t$aldeb_ra_radians\t$aldeb_dec_radians "); my $t = localtime; my $jd = $t->julian_day; $logger->info("Time is $t"); $logger->info("Julian day is $jd"); __END__

For SSCCE followers in need of a conf file for Log::Log4perl:

###################################################################### +######### # Log::Log4perl Conf + # ###################################################################### +######### log4perl.rootLogger = INFO, LOG1, SCREEN log4perl.appender.SCREEN = Log::Log4perl::Appender::Screen log4perl.appender.SCREEN.stderr = 0 log4perl.appender.SCREEN.layout = Log::Log4perl::Layout::PatternLayou +t log4perl.appender.SCREEN.layout.ConversionPattern = %m %n log4perl.appender.LOG1 = Log::Log4perl::Appender::File log4perl.appender.LOG1.filename = /home/hogan/Documents/hogan/logs/4. +log4perl.txt log4perl.appender.LOG1.mode = append log4perl.appender.LOG1.layout = Log::Log4perl::Layout::PatternLayou +t log4perl.appender.LOG1.layout.ConversionPattern = %d %p %m %n

wrapping scripts with perl

Calling External Commands More Safely has been a haukex post and forum standard for system calls. I'd like to pursue this a bit and where it might not be just one line. Extending what I have:

fritz@laptop:~/Documents/gitlab1$ ./2.2023.pl Time is Sat Feb 25 17:09:31 2023 Julian day is 2460001.5066088 ./2.2023.pl Alnitak Alnilam Mintaka # systemx: Hello, World! # capturex: Hello, World! $VAR1 = 'Coordinates(ICRS,ep=J2000,eq=2000): 05 40 45.52666 -01 56 33 +.2649 (Opt ) A [5.19 2.29 90] 2007A&A...474..653V'; $VAR1 = 'Coordinates(ICRS,ep=J2000,eq=2000): 05 36 12.81335 -01 12 0 +6.9089 (Opt ) A [3.69 1.67 90] 2007A&A...474..653V'; $VAR1 = 'Coordinates(ICRS,ep=J2000,eq=2000): 05 32 00.40009 -00 17 5 +6.7424 (Opt ) A [4.92 2.38 90] 2007A&A...474..653V'; "git clone something" failed to start: "No such file or directory" at +./2.2023.pl line 43. fritz@laptop:~/Documents/gitlab1$ git clone something fatal: repository 'something' does not exist fritz@laptop:~/Documents/gitlab1$

Q3: How do I capture the 3 numeric fields for declination and Right Ascension, dealing with the potential minus sign?

Q4: How do I do a sanity check on these values without reinventing a wheel which someone else has almost certainly created already?

Above we see STDOUT as it plays the systemx stuff. I have the initial success with the stars that comprise Orion's belt, but I would say that everything that followed failed, at least to match the writer's intent. It would seem that they are not being interpreted by something that knows BASH. Perl source:

#!/usr/bin/perl use v5.030; use Time::Piece; use Log::Log4perl; my $t = localtime; my $jd = $t->julian_day; my $log_conf4 = '/home/fritz/Documents/perlmonks/conf_files/4.conf'; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("Time is $t"); $logger->info("Julian day is $jd"); $logger->info("$0"); my @belt= qw/ Alnitak Alnilam Mintaka/; $logger->info("@belt"); use IPC::System::Simple qw/systemx capturex/; $logger->info("# systemx:"); systemx 'echo', 'Hello,', 'World!'; my $stdout = capturex 'echo', 'Hello,', 'World!'; $logger->info("# capturex: $stdout"); my @captured; for(@belt){ my $stdout = capturex 'perl', '1.simbad.pl', "$_"; push @captured, $stdout; } $logger->info("@captured"); #my $s1 = capturex 'set -eu'; # "set -eu" failed to start: "No such fi +le or directory" #$logger->info("s1 is $s1"); #my $s2 = capturex 'read repo'; # "read repo" failed to start: "No suc +h file or directory" #$logger->info("s2 is $s2"); my $group='perlmonks'; #my $repo = systemx 'read repo'; #$logger->info("s2 is $repo"); #my $command="git clone git/@gitlab.com:$group//$repo.git"; my $command="git clone something"; my $s3 = capturex "$command"; $logger->info("# capturex: $command"); $logger->info("# capturex output: $s3"); __END__

So, I'm shooting blanks for some reason and want to change tack. Let's try wrapping a bash script:

my $command="./5.git.sh"; my $s3 = capturex "$command"; $logger->info("# capturex: $command"); $logger->info("# capturex output: $s3");

I get the perl output but none of the bash script, which was helpful for what it was, and I'd like to write something like a perl equivalent for it:

#!/bin/bash pwd >README.md echo -n "Please enter email: " read email git config --global user.email $email ... git push -u origin master git push -u master origin

I also don't really know how to push and pull things yet, but that's part of the learning curve.

Anyways, so I'm looking for ways either wrap a bash script correctly or abrogate the wrapper by implementing it in perl.

Thanks for your comment,


In reply to wrapping bash and astronomy by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.