0

Crashdump emailer for compiled programs

Free lines Bash 4 revisions 131 3 months ago 3 months ago
#!/bin/sh
#
# save as email-crash.sh
# run as "./email-crash.sh <your-executable-name> <your-email-address> <coredump dir>"
#
/usr/bin/gdb -batch -ex "set pagination off" -ex "bt full" $1 `ls -Art $3/*core* | tail -n 1` | grep -v ^"No stack."$ | mail -s "A wild crash has arrived: stack trace attached" $2

When your program crashes, you want a way to get the stack trace (backtrace) to a developer.

This script will do it simply using gdb and mail. Run it with the executable name, your email address and the directory where the program stores coredumps on crash. For example:

./email-crash.sh ./bot [email protected] /var/tmp/cores