Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run remote commands with --login #28

Open
JosuaKrause opened this issue Dec 28, 2016 · 4 comments
Open

Run remote commands with --login #28

JosuaKrause opened this issue Dec 28, 2016 · 4 comments

Comments

@JosuaKrause
Copy link
Contributor

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
Copy link
Member

remram44 commented Jan 4, 2017

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
Copy link
Contributor Author

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
Copy link
Member

remram44 commented Jan 6, 2017

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants