there's been a few people discussing this in various places, but I wrote a script I thought I'd share.
After a flash update some time ago, it started deleting the /tmp/Flash* video files so we couldn't just copy them. But this script restores them while they're still loaded in the browser... sort of. after your flash video is fully loaded, run the script and it'll appear in the same directory. it won't be *the* file that your browser is using, but it's the same file name just on a different inode. I don't fully understand how the kernel works with this, but meh. it works.
Code:
#!/bin/bash
flashdir="/tmp/"
mkdir -p "$flashdir" 2>/dev/null
function get_files {
stat /proc/$1/fd/* |
grep 'Flash.* (deleted)' | # we're looking only for deleted flash files
sed "s/.*File: \`\(.*\)' ->.*\(Flash[a-zA-Z0-9]*\).*/\1 \2/g" # prune out the proc/*/fd/* path as well as the deleted file path
}
function get_processes {
ps ax |
grep flash -i |
grep -v grep | # not the grep process
grep -v "$1" | # not the script process
sed 's/^ *\([0-9]*\) .*/\1/g' # prune out the PID
}
processes=(`get_processes "$0"`) # put all flash processes in the array
for p in ${processes[@]} ; do
files=(`get_files "$p"`) # put all files for this flash process in the array
# restore the flash files...
for (( i=0; $i < ${#files[@]}; i+=2 )); do
if [[ ! -e "$flashdir/${files[$i+1]}" ]] ; then
echo "--> copying \"${files[$i]}\" \"$flashdir/${files[$i+1]}\""
cp "${files[$i]}" "$flashdir/${files[$i+1]}"
else
echo "--> already copied \"${files[$i]}\" \"$flashdir/${files[$i+1]}\""
fi
done
done