Created
December 31, 2011 14:21
-
-
Save venj/1544115 to your computer and use it in GitHub Desktop.
Inject F-Script to a named process. This script is based on the Inject F-Script service. Kinda useful when some apps do not provide the standard services menu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo Usage: `basename $0` Process_Name | |
} | |
if [ $# -ne 1 ]; then | |
usage | |
exit 1 | |
fi | |
pid=$(pidof $1 | awk -F' ' '{print $1}') | |
if [ -z $pid ];then | |
echo No such process: $1 | |
exit 255 | |
fi | |
cat > /tmp/run_gdb << EOF | |
sudo -u `whoami` gdb --pid $pid --batch --nx --command=/dev/stdin << EOT | |
p (char)[[NSBundle bundleWithPath:@"/Library/Frameworks/FScript.framework"] load] | |
p (void)[FScriptMenuItem insertInMainMenu] | |
EOT | |
EOF | |
osascript -e "tell application \"System Events\" | |
set pid to $pid | |
end tell | |
do shell script \"sh /tmp/run_gdb \" & pid" | |
unset pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment