VisTrails / tej

Trivial Extensible Job-submission -- a simple (no setup on the server) but extensible (in case you need scheduling/queueing) job submission mechanism in Python
BSD 3-Clause "New" or "Revised" License
8 stars 3 forks source link

Run remote commands with --login #28

Open JosuaKrause opened 7 years ago

JosuaKrause commented 7 years ago

The --login (-l) option advises sh to act like a login shell (which is not the case when normally invoked by ssh) and source /etc/profile and one of ~/.bash_profile, ~/.bash_login, and ~/.profile. This makes commands run in user specified environments and also enables built-ins like the module command. The behavior can currently be achieved by passing "sh -l " + your_command to submit.

remram44 commented 7 years ago

The problem here is that the script parameter was initially supposed to be a file, part of the job. In particular, the server needs to set +x before running it.

I have no way of supporting files and commands both with and without --login here. Perhaps wrapping in sh -l should be the expected way to do this? (this is what tej would do anyway)

def login_shell(command):
    return '/bin/sh -l -c %s' % tej.submission.shell_escape(command)

queue.submit(None, mydir, login_shell('which conda'))
JosuaKrause commented 7 years ago

hmm, why do you need to support without --login? Also, if you run the command / file via '/bin/sh -l -c %s' % tej.submission.shell_escape(command) you don't need to set +x for the file.

remram44 commented 7 years ago

It actually does need to be +x for your above command to work (it's gonna expand to '/bin/sh -l -c "./script"'). Not using -c wouldn't need +x, but then it can only be a bash script.

JosuaKrause commented 7 years ago

I see, yes I'm currently doing it without -c but I see the problem with normal commands. But the +x code is already in place anyway.