I found your question interesting so I tried to figure out how to do it.
I thought this: create a script that could delete itself after being run. This way the script could do its job and then ... goodbye!
Here's the code
#!/bin/bash
# Test script based on informations found on
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
# trying to understand if it's possibile to achieve what asked on
# http://askubuntu.com/questions/161682/how-to-run-a-script-only-a-single-time-ever
# Let's try to find in which directory the script is
# It should account for spaces, link, etc.
SOURCE="${BASH_SOURCE[0]}"
DIR="$( dirname "$SOURCE" )"
while [ -h "$SOURCE" ]
do
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# We know the name of the script from 'basename $0'
NAME=`basename $0`
# Merge them to have the full path to the script
FULL_PATH=$DIR/$NAME
echo $FULL_PATH
# Let's be a bit theatrical
echo "This script will self destruct in"
for ((i=5;i>0;i--))
do
echo $i
sleep 1
done
# Goodbye!
rm $FULL_PATH
Save this test code and make it executable to test it.
Remember it deletes itself when it's run so don't forget to have a backup before testing it!