#!/usr/bin/perl
use v5.030; # strictness implied
use warnings;
use Path::Tiny;
use Time::Piece;
use Log::Log4perl;
use IPC::System::Simple qw/systemx capturex/;
use utf8;
my ($argv1) = @ARGV;
if (not defined $argv1) {
die "Need argv1\n";
}
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 ($path) = @ARGV;
if (not defined $path) {
die "Need path in\n";
}
my $file_in = path("$path");
my @lines = $file_in->lines_utf8;
my @commands;
#
for my $line (@lines){
if ( $line =~ /^(?:#|$)/){
say "line matched $line";
next;
}
else {
push( @commands, $line );
}
}
say @commands;
say "cardinality: ", scalar @commands;
my $target_dir = path('/tmp');
my $tempfile = $target_dir->tempfile('foobarXXXXXX');
$tempfile->spew("@commands"); # not atomic
my $capture = capturex "bash", $tempfile;
$logger->info("capx: $capture");
__END__
####
fritz@laptop:~/Documents/gitlab1$ ./1.wrap.pl 3.git.sh
Time is Sun Aug 18 01:08:20 2024
Julian day is 2460540.7974537
./1.wrap.pl
line matched #!/bin/bash
line matched #echo "starting fresh with rm -rf .git"
line matched #rm -rf .git | tee 1.txt
line matched #git init
line matched #ls >README.md
line matched #git remote add origin git@gitlab.com:perlmonks/$1.git
line matched #git push -uf master main | tee 2.txt
line matched
####
pwd >2.txt
git add *.pl
git add *.sh
git add *.txt
git commit -m 'next revision' | tee 2.txt
git push -uf origin master | tee 2.txt
cardinality: 6
remote:
remote: ========================================================================
remote:
remote: ERROR: Your SSH key has expired.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
capx: On branch master
...