0

I'm doing a bash query using subprocess over SSH (don't ask). The query includes using find with the -exec option, however, on the remote target host, {} won't expand properly, when viewing what the query actually does on the target host.

For example: find / -name "hello.txt" -exec echo {} \; where {} should read hello.txt but it merely reads just as {}.

So, what I'm I missing here?

Thanks in advance.

1 Answer 1

4

It would be helpful if you posted some code, but my guess is that you are not including shell=True in your subprocess arguments, which is necessary for the variable expansion. For example:

subprocess.Popen('find / -name "hello.txt" -exec echo {} \;', shell=True)
Sign up to request clarification or add additional context in comments.

1 Comment

Yupp, I know :-) Code is on another machine. But you're correct, using shell=False.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.