Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Check if sudo
- if [ $UID -ne 0 ]; then
- echo "You have to run this as sudo" 1>&2
- exit 1
- fi
- # Get the date for the check
- read -p "Please input a date, format 'Jan 12': " chosendate
- # Get the time for the check
- read -p "Please input the time, format '13:55', leave blank for no time: " chosentime
- # Get last results based on input
- gotresults=$(last |grep "$chosendate $chosentime" |awk '{print $1" " $5" " $6" " $7" " $9}')
- if [[ $(echo "$gotresults"|wc -l) -ne 1 ]]; then
- echo "There are multiple entries corresponding to your input"
- echo
- echo "$gotresults"
- echo
- read -p "Please select which entry you desire by typing in the time: " chosentime
- echo "$gotresults" |grep $chosentime
- else
- echo "$gotresults"
- fi
- #!/bin/bash
- # Check if sudo
- if [ $UID -ne 0 ]; then
- echo "You have to run this as sudo" 1>&2
- exit 1
- fi
- **FLAG1**
- # Get the date for the check
- read -p "Please input a date, format 'Jan 12': " chosendate
- # Get the time for the check
- read -p "Please input the time, format '13:55', leave blank for no time: " chosentime
- # Get last results based on input
- gotresults=$(last |grep "$chosendate $chosentime" |awk '{print $1" " $5" " $6" " $7" " $9}')
- if [[ $(echo "$gotresults"|wc -l) -ne 1 ]]; then
- echo "There are multiple entries corresponding to your input"
- echo
- echo "$gotresults"
- echo
- echo "Please select a date/time that only returns one value"
- **GO TO FLAG1**
- else
- echo "$gotresults"
- fi
Add Comment
Please, Sign In to add comment