0

I am looking to run the following bash script with python:

sed -n -e '/SCN/,/^\s*$/p' $@ > Junction-Links.txt

The bash script is saved as ext-jun-links.sh and I want to run it using Python to pass a file name in place of the $@.

I am currently trying to use the below code to do so:

import subprocess
from subprocess import call
    
subprocess.run(["./ext-jun-links.sh","NETL1405.TXT"], shell=True)

However, this gives me the error below:

'ext-jun-links.sh' is not recognized as an internal or external command, operable program or batch file.

Is there a way to solve this error? The bash file runs fine when using PowerShell with the following code, so that's not the issue:

bash ext-jun-links.sh 'NETL1405.TXT'

1 Answer 1

1

I think it's cus' you're trying to execute a bash script via PowerShell.

bash ext-jun-links.sh 'NETL1405.TXT'

This works, because you're feeding ext-jun-links.sh and 'NETL1405.TXT' as params to bash.

try:

subprocess.run(["bash", "./ext-jun-links.sh","NETL1405.TXT"], shell=True)
Sign up to request clarification or add additional context in comments.

1 Comment

Do you really need shell=True for that?

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.