I'm trying to run a script (let's call it test.sh
) via ssh as follows
ssh ${user}@${ip} "python3 test.py"
and the test.py is as follows
import os
# Do sth
...
os.system("emulator xxx")
...
The android environemnt paths are exported in ~/.bashrc
, but the above cmd failed due to missing ${ANDROID_SDK_ROOT}. I know it's because ssh ${user}@{ip} cmd
will setup a non-login and non-interactive shell, but I wonder if there is any solution?
PS:
I have tried #!/bin/bash --login
and it failed.
CodePudding user response:
Try this:
ssh -t ${user}@${ip} "bash -i -c 'python3 test.py'"