Is a script to run a command within a virtualenv missing from virtualenv?

Sometimes the python command in the virtualenv isn’t quite enough.

Contents of script run_with_env.sh:

#!/bin/sh

envdir=$1
shift

curdir=$1
shift

. $envdir/bin/activate && cd $curdir && exec "$@"

This runs a specified command (plus arguments) in a particular directory within a particular virtualenv.

Example use:

$ crontab -l
...
30 0 * * * /home/trawick/myhg/apache/bin/run_with_env.sh git/edurepo/envs/edurepo git/edurepo/src/edurepo python teachers/pretend_teacher.py
...

July 4 update:

See also vex.