Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this is two files,
- # cut at #### lines, use proposed names or adjust 'lsflash' in 2nd script
- # to point at the first file
- ########## lsflash ##########
- #!/bin/sh
- # linux version
- # on mac os, do:
- # ls /private/var/folders/*/*/-Tmp-/FlashTmp.*
- ### adjust these to match your system
- # PROCNAMES is a comma-separated list of programs to match with ps
- # *DO NOT* include spaces, ps doesn't like these
- PROCNAMES="chromium-browser,npviewer.bin"
- # FILEPATTERN is a regular expression to match against the files with grep
- FILEPATTERN="/tmp/Flash"
- ### END adjustments, rest should work fine
- # get all matching pids
- for pid in `ps -C $PROCNAMES -o 'pid='`; do {
- # get those that have a flash video open
- if [ -n "`ls -l /proc/$pid/fd/ 2>/dev/null | grep $FILEPATTERN`" ]; then {
- # output their PID...
- echo "%%%PID=$pid";
- # ...and all matching file descriptors
- ls -l /proc/$pid/fd | grep $FILEPATTERN;
- }
- fi
- }
- done | awk '\
- /^%%%PID=.*/ { gsub(".*=",""); pid = $1; next } \
- { print "/proc/" pid "/fd/" $8 } \
- '
- ########## getflash-all ##########
- #!/bin/sh
- # where to copy the files
- TARGETDIR="/tmp/flash/"
- mkdir -p $TARGETDIR
- for file in `lsflash`; do cp $file $TARGETDIR; done
- # optional: open file manager (nautilus, thunar, $whatever)
- #nautilus $TARGETDIR
Add Comment
Please, Sign In to add comment