Notes for one-liner fans. "Here" files are OK, but a one-liner is easiest to copy & paste.
After a bit of trial & error, I came up with: # Run 'empty' on 'gdb -q audacious2' to automate 'gdb' session. # Output results to a temp file. empty -f -L /tmp/e.log gdb -q audacious2 ; empty -w 'gdb)' 'run\n' ; empty -w 'gdb)' 'thread apply all backtrace\n' ; empty -s 'q\n' ; empty -s 'y\n' ; empty -k ; cat /tmp/e.log ...it uses the minimum-overhead 'empty' util, found in Debian's 'empty-expect' package. Tricky syntax 'empty' has, it needs an easier front-end util. Attached is a simple 'empty' front-end script; not robust, (multiple instances would probably mess up), but it works. New one-liner: empty-ez.sh 'gdb -q audacious2' 'gdb)' 'run' 'gdb)' 'thread apply all backtrace' '' 'q' '' 'y' HTH...
#!/bin/sh if [ $# -eq 0 ] ; then echo "Purpose -- '$0' is an easier front-end for 'empty'" echo "Usage: $0 'command [args...]' 'prompt1' 'response1' 'prompt2' 'response2' ..." exit 1 fi LOG=/tmp/empty-ez.log empty -f -L $LOG $1 shift while [ "$2" ] do empty -w "$1" "$2"'\n' shift 2 done empty -k 2> /dev/null cat $LOG rm $LOG