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

source prolog file not working #74

Open
nikoladze opened this issue Sep 12, 2018 · 1 comment
Open

source prolog file not working #74

nikoladze opened this issue Sep 12, 2018 · 1 comment

Comments

@nikoladze
Copy link

Hi,

When i pass a file by the --prolog argument i get the error message:

OSError: [Errno 2] No such file or directory

originating from the subprocess.Popen call in:

if self.isLocal():
# Launching local workers
c = self._getWorkerCommandList()
self.subprocesses.append(subprocess.Popen(c))

The error seems to refer to the bash builtin source. When i run the above command with shell=True and executable="/bin/bash" it seems to work

self.subprocesses.append(subprocess.Popen(" ".join(c), shell=True, executable="/bin/bash"))

I'm aware this poses security risks and i have no overview which (potentially un-escaped) external inputs go into this command, so i'm not suggesting to just fix it in this way. Also i don't know if relying on bash is the only way to do this.
Maybe somebody has an idea?

Cheers,
Nikolai

@ljluestc
Copy link

import subprocess
import shlex

Construct the subprocess command

prolog_command = [
'/full/path/to/your/prolog_script.sh',
'arg1',
'arg2',
]

Escape and join the command arguments

escaped_command = ' '.join(shlex.quote(arg) for arg in prolog_command)

Run the subprocess

subprocess.Popen(escaped_command, shell=True, executable="/bin/bash")

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

No branches or pull requests

2 participants