Files
Bash/uapay.sh
T

64 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
#################################################
# Query Univeristy of Arizona payroll information
# Written by Justin Oros
# Usage: uapay.sh FirstName LastName
#################################################
2023-07-09 19:31:26 -07:00
# BASH present?
if [ ! -f /bin/bash ]; then
echo "Bash not found!"
exit 0
fi
2023-07-09 19:31:26 -07:00
# CURL present?
if [ ! -f /usr/bin/curl ]; then
echo "Curl not found!"
exit 0
fi
2023-07-09 19:31:26 -07:00
# GREP present?
if [ ! -f /usr/bin/grep ]; then
echo "Grep not found!"
exit 0
fi
2023-07-09 19:31:26 -07:00
# UA Payroll URL
uapay_url='https://openpayrolls.com/employee'
# User Agent
uapay_useragent='Chrome/79'
2023-07-09 19:31:26 -07:00
# Get Input
if [ -z "$1" ] || [ -z "$2" ]; then
echo -e "\nUsage: uapay.sh FirstName LastName\n"
exit 0
else
2023-07-09 19:31:26 -07:00
for i in "$@"
do
uapay_name="$@"
done
fi
2023-07-09 19:31:26 -07:00
# Format Input
uapay_formatted_name=${uapay_name// /-}-4329
# Grep Filter
uapay_filter="and a pay of"
# Query URL
2023-07-09 19:31:26 -07:00
uapay_query=$(curl -s -k --user-agent $uapay_useragent $uapay_url/$uapay_formatted_name | grep "$uapay_filter")
2023-07-09 19:31:26 -07:00
# Check Results
if [ -z "$uapay_query" ]; then
echo -e "\n$uapay_name was not found.\n"
2023-07-09 14:23:32 -07:00
exit 0
fi
2023-07-09 19:31:26 -07:00
# Format Output
uapay_query=${uapay_query/\<p class=\"lead font-16 font-weight-400\"\>/}
uapay_query=${uapay_query/\<\/p\>/}
2023-07-09 19:31:26 -07:00
# Print Output
echo -e "\n$uapay_query\n"