I am trying to set up a cron job to run regression tests for software that usually runs in an interactive environment (CASA, for the morbidly curious: http://casa.nrao.edu/). I have a shell script, which, in MWE form (mwe.sh
), does:
casapy -c mwe.py
where it is supposed to execute that script. casapy
is a fairly complicated bit of business that does a lot of things internally, including importing and setting up an ipython client for multiprocessing.
Here is my problem:
If I run the code interactively, i.e. type casapy -c mwe.py
on the bash shell command line, it works.
If I run:
source mwe.sh
the code still runs exactly as expected and performs the tests. Great!
If instead, I run
bash mwe.sh
the startup script hangs permanently. I've tracked this down to a few different locations in the startup script that all are capable of independently failing.
So, my question: What are the differences between starting commands in the interactive shell environment and from within a script? Especially, what are the differences that can be narrowed down to differences between source file.sh
and sh file.sh
?
In particular, in the context of the cron job I'm trying to run, is there any way to do the equivalent of source
ing a file on the interactive command line?
EDIT: one last piece of information - I think this failure only happens on mac, not on linux, but I don't know if that provides any useful information at all because the underlying code is somewhat different for the two platforms.