Guest User

Untitled

a guest
Oct 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Check if sudo
  4. if [ $UID -ne 0 ]; then
  5. echo "You have to run this as sudo" 1>&2
  6. exit 1
  7. fi
  8.  
  9. # Get the date for the check
  10. read -p "Please input a date, format 'Jan 12': " chosendate
  11.  
  12. # Get the time for the check
  13. read -p "Please input the time, format '13:55', leave blank for no time: " chosentime
  14.  
  15. # Get last results based on input
  16. gotresults=$(last |grep "$chosendate $chosentime" |awk '{print $1" " $5" " $6" " $7" " $9}')
  17.  
  18. if [[ $(echo "$gotresults"|wc -l) -ne 1 ]]; then
  19. echo "There are multiple entries corresponding to your input"
  20. echo
  21. echo "$gotresults"
  22. echo
  23. read -p "Please select which entry you desire by typing in the time: " chosentime
  24. echo "$gotresults" |grep $chosentime
  25. else
  26. echo "$gotresults"
  27. fi
  28.  
  29. #!/bin/bash
  30.  
  31. # Check if sudo
  32. if [ $UID -ne 0 ]; then
  33. echo "You have to run this as sudo" 1>&2
  34. exit 1
  35. fi
  36.  
  37. **FLAG1**
  38. # Get the date for the check
  39. read -p "Please input a date, format 'Jan 12': " chosendate
  40.  
  41. # Get the time for the check
  42. read -p "Please input the time, format '13:55', leave blank for no time: " chosentime
  43.  
  44. # Get last results based on input
  45. gotresults=$(last |grep "$chosendate $chosentime" |awk '{print $1" " $5" " $6" " $7" " $9}')
  46.  
  47. if [[ $(echo "$gotresults"|wc -l) -ne 1 ]]; then
  48. echo "There are multiple entries corresponding to your input"
  49. echo
  50. echo "$gotresults"
  51. echo
  52. echo "Please select a date/time that only returns one value"
  53. **GO TO FLAG1**
  54.  
  55. else
  56. echo "$gotresults"
  57. fi
Add Comment
Please, Sign In to add comment