Adding Perl 5 version of scripts
This commit is contained in:
parent
c6373cc762
commit
572704fbb0
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env perl
|
||||
use 5.10.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use DateTime;
|
||||
use Net::Telnet ();
|
||||
|
||||
# Skip on weekends
|
||||
my $day_of_week = DateTime->now->day_of_week();
|
||||
exit if $day_of_week == 6 || $day_of_week == 7;
|
||||
|
||||
|
||||
# Exit early if no sessions with my username are found
|
||||
exit unless `who | grep $ENV{USER}`;
|
||||
|
||||
|
||||
#my $coffee_machine_ip = '10.10.42.42';
|
||||
my $coffee_machine_ip = 'localhost';
|
||||
my $password = '1234';
|
||||
my $delay = 24;
|
||||
|
||||
|
||||
my $con = Net::Telnet->new(
|
||||
-host => $coffee_machine_ip, -timeout => 30
|
||||
);
|
||||
$con->waitfor('/password: $/i');
|
||||
$con->print($password);
|
||||
$con->cmd('sys brew');
|
||||
sleep $delay;
|
||||
$con->cmd('sys pour');
|
||||
$con->close;
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env perl
|
||||
use 5.10.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use DateTime;
|
||||
use SMS::Send::Twilio;
|
||||
|
||||
# Skip on weekends
|
||||
my $day_of_week = DateTime->now->day_of_week();
|
||||
exit if $day_of_week == 6 || $day_of_week == 7;
|
||||
|
||||
|
||||
# Exit early if no sessions with my username are found
|
||||
exit unless `who | grep $ENV{USER}`;
|
||||
|
||||
# Phone numbers
|
||||
my $MY_NUMBER = '+xxx';
|
||||
my $NUMBER_OF_BOSS = '+xxx';
|
||||
|
||||
my $EXCUSES = [
|
||||
'Locked out',
|
||||
'Pipes broke',
|
||||
'Food poisoning',
|
||||
'Not feeling well',
|
||||
];
|
||||
|
||||
my $rand = int(rand(scalar(@$EXCUSES)));
|
||||
|
||||
my $random_excuse = $EXCUSES->[$rand];
|
||||
my $message = "Gonna work from home. ${random_excuse}";
|
||||
|
||||
# Send a text message
|
||||
my $twilio = SMS::Send->new('Twilio',
|
||||
_accountsid => $ENV{TWILIO_ACCOUNT_SID},
|
||||
_authtoken => $ENV{TWILIO_AUTH_TOKEN},
|
||||
_from => $MY_NUMBER,
|
||||
);
|
||||
|
||||
my $sent = $sender->send_sms(
|
||||
text => $message, to => $NUMBER_OF_BOSS
|
||||
);
|
||||
|
||||
# Log errors
|
||||
die "Failed to send SMS" if not $sent;
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env perl
|
||||
use 5.10.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env perl
|
||||
use 5.10.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use DateTime;
|
||||
use SMS::Send::Twilio;
|
||||
|
||||
# Skip on weekends
|
||||
my $day_of_week = DateTime->now->day_of_week();
|
||||
exit if $day_of_week == 6 || $day_of_week == 7;
|
||||
|
||||
|
||||
# Exit early if no sessions with my username are found
|
||||
exit unless `who | grep $ENV{USER}`;
|
||||
|
||||
# Phone numbers
|
||||
my $MY_NUMBER = '+xxx';
|
||||
my $HER_NUMBER = '+xxx';
|
||||
|
||||
my $REASONS = [
|
||||
'Working hard',
|
||||
'Gotta ship this feature',
|
||||
'Someone fucked the system again',
|
||||
];
|
||||
|
||||
my $rand = int(rand(scalar(@$REASONS)));
|
||||
|
||||
my $random_reason = $REASONS->[$rand];
|
||||
my $message = "Late at work. ${random_reason}";
|
||||
|
||||
# Send a text message
|
||||
my $twilio = SMS::Send->new('Twilio',
|
||||
_accountsid => $ENV{TWILIO_ACCOUNT_SID},
|
||||
_authtoken => $ENV{TWILIO_AUTH_TOKEN},
|
||||
_from => $MY_NUMBER,
|
||||
);
|
||||
|
||||
my $sent = $sender->send_sms(
|
||||
text => $message, to => $HER_NUMBER
|
||||
);
|
||||
|
||||
# Log errors
|
||||
die "Failed to send SMS" if not $sent;
|
||||
|
||||
Loading…
Reference in New Issue