3

I want to call from python a shell script which contain the running of another python function. I would like to use for that subprocess method. My code so far look like:

arguments = ["./my_shell.sh", path]
ret_val = subprocess.Popen(arguments, stdout=subprocess.PIPE)

while the script is the following:

#!/bin/sh

cd ... 
python -c "from file import method; 
method()"

How can I give in the directory (to cd) of the path that I pass as an argument in the shell file?

1 Answer 1

1

You can access your arguments as $1, $2, etc. So your cd command would simply be cd $1.

Sign up to request clarification or add additional context in comments.

Comments

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.