On Unix, I can run Python scripts from the command line like this1:
PYTHONPATH=lib/python path/to/script.py The setting of PYTHONPATH affects the run-time value of the sys.path variable, which is Python's equivalent of Mathematica's $Path variable.
For example:
% PYTHONPATH=/foo:/bar:/baz python -c 'import sys; print sys.path[1:4]' ['/foo', '/bar', '/baz'] Is there a similar way to modify the value of the $Path variable from the command line when invoking WolframScripts?
1 Of course, I can omit the PYTHONPATH=lib/python "prefix" by first running export PYTHONPATH=/absolute/path/to/lib/python. The form with the "prefix", however, gives me the flexibility to tailor the library path to the script, something I often find useful.
mathkernel -run '$Path=...'? $\endgroup$MATHEMATICA_BASEandMATHEMATICA_USERBASE, however, I concluded that Mathematica interprets them sufficiently differently from what I have in mind that decided to go with a different solution. (I've posted this solution as an answer, below.) $\endgroup$