Skip to content

Instantly share code, notes, and snippets.

@agalazis
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agalazis/e747b448100fbf8633a8 to your computer and use it in GitHub Desktop.
Save agalazis/e747b448100fbf8633a8 to your computer and use it in GitHub Desktop.
sample stdout spying script for a process using strace (in this case for mplayer)
#track all (write sys call) output but clear from system call functions(only the text in quotes)
strace -p$(pgrep mplayer |head -n1 ) -s9999 -e write 2>&1 |grep -Po '".*?"'
#track volume changes
strace -p$(pgrep mplayer |head -n1 ) -s9999 -e write 2>&1 |grep -Po 'KVolume.*? %'
#track information and volume changes
strace -p$(pgrep mplayer |head -n1 ) -s9999 -e write 2>&1 |grep -Po 'KVolume.*? %|Title:.*?\\n|Album:.*?\\n|Year:.*?\\n|Track:.*?\\n'
#or
strace -p$(pgrep mplayer |head -n1 ) -s9999 -e write 2>&1 |grep -Po 'KVolume.*?\\n|Title:.*?\\n|Album:.*?\\n|Year:.*?\\n|Track:.*?\\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment