Guest User

Untitled

a guest
May 24th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.36 KB | None | 0 0
  1. # this is two files,
  2. # cut at #### lines, use proposed names or adjust 'lsflash' in 2nd script
  3. # to point at the first file
  4. ########## lsflash ##########
  5. #!/bin/sh
  6. # linux version
  7. # on mac os, do:
  8. # ls /private/var/folders/*/*/-Tmp-/FlashTmp.*
  9.  
  10. ### adjust these to match your system
  11. # PROCNAMES is a comma-separated list of programs to match with ps
  12. # *DO NOT* include spaces, ps doesn't like these
  13. PROCNAMES="chromium-browser,npviewer.bin"
  14. # FILEPATTERN is a regular expression to match against the files with grep
  15. FILEPATTERN="/tmp/Flash"
  16.  
  17. ### END adjustments, rest should work fine
  18.  
  19. # get all matching pids
  20. for pid in `ps -C $PROCNAMES -o 'pid='`; do {
  21.         # get those that have a flash video open
  22.         if [ -n "`ls -l /proc/$pid/fd/ 2>/dev/null | grep $FILEPATTERN`" ]; then {
  23.             # output their PID...
  24.             echo "%%%PID=$pid";
  25.             # ...and all matching file descriptors
  26.             ls -l /proc/$pid/fd | grep $FILEPATTERN;
  27.         }
  28.         fi
  29.         }
  30. done | awk '\
  31. /^%%%PID=.*/ { gsub(".*=",""); pid = $1; next } \
  32. { print "/proc/" pid "/fd/" $8 } \
  33. '
  34.  
  35. ########## getflash-all ##########
  36. #!/bin/sh
  37.  
  38. # where to copy the files
  39. TARGETDIR="/tmp/flash/"
  40.  
  41. mkdir -p $TARGETDIR
  42.  
  43. for file in `lsflash`; do cp $file $TARGETDIR; done
  44.  
  45. # optional: open file manager (nautilus, thunar, $whatever)
  46. #nautilus $TARGETDIR
Add Comment
Please, Sign In to add comment