To-Slalom

FTP_screenshot

May 10th, 2021 (edited)
740
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #########################################
  4. # basic script to take a screen shot    #
  5. # and send it to web server             #
  6. # using scrot and ftpput apps           #
  7. # test it in BusterPup and fossa64      #
  8. #########################################
  9.  
  10. ########################
  11. # printscreen settings #
  12. ########################
  13. #delay="5";                 # program loop delay in seconds
  14. delay_snap="3"              # screen capture delay in seconds
  15. quality="75"                # scale of 1-100
  16. thumb="25"                  # thumbnail size as percentage
  17. ######################
  18. # webserver settings #
  19. ######################
  20. host_n="hostname"           # hostname
  21. user_n="username"           # username
  22. pass_w="password"           # password
  23. door_n="21"                 # port number
  24. dest_p=""                   # webserver path if blank goes to root of the webserver
  25. orig_p="/$USER/"            # Local path by default /root/
  26. file_n="currentscreen.jpg"  # name of the file of the the print to send
  27. ######################################################
  28. # lets check if we have the app(s) install in our OS #
  29. ######################################################
  30. list=( scrot ftpput )
  31. for i in "${list[@]}" ; do
  32.     if ! command -v $i &> /dev/null ; then
  33.         echo "$i isnt install yet"
  34.         exit
  35.     fi
  36. done
  37. #####################################################################################
  38. # since busterPup use scrot version 0.8-33 and fossa64 version 1.2                  #
  39. # i have made a condition to overwirte the file in version 1.2 using the option -o  #
  40. #####################################################################################
  41. version=$(scrot --version | head -1 | grep -oE "*[0-9]{1}.[0-9]{1}")
  42. if [[ ${version%.*} -ge 1 ]] ; then overwrite="-o" ; else overwrite="" ; fi
  43. #####################################################
  44. # lets check if image is created with sucess or not #
  45. #####################################################
  46. # screen="$(scrot $orig_p$file_n -d $delay_snap --thumb $thumb --quality $quality)"
  47. if ! $(scrot ${overwrite} $orig_p$file_n -d $delay_snap --quality $quality ) ; then
  48.     echo " scrot error creating file run scrot without  &> /dev/null to see error "
  49.     exit
  50. fi
  51. #################################################
  52. # lets check if file is send with sucess or not #
  53. #################################################
  54. if ! $(ftpput -P ${door_n} -u ${user_n} -p ${pass_w} ${host_n} ${dest_p}${file_n} ${orig_p}${file_n} &> /dev/null ) ; then
  55.     echo " ftpput error run ftpput without  &> /dev/null to see error "
  56.     exit
  57. else
  58.     echo "File ${file_n} send with sucess to webserver"
  59. fi
  60.  
RAW Paste Data