0

I want to be able to open a CLI program with arguments and take a users input. If i do it manually it looks like this

'/programfilepath' -i '/inputfile' -x asdf -o '/output path'

Because i need the user to be able to enter the input file i have it like this

import os
question1=input('What is the input file': )
os.system("'/programfilepath' -i question1 -x asdf -o '/output path'")

This is not working correctly after the user inputs the file and in terminal its giving me an output saying

sh1: 1: (string above with input file displayed correctly): not found

I know this is a formatting issue but im not sure of my exact issue thats causing issues.

1
  • use os.system(f"'/programfilepath' -i {question1} -x asdf -o '/output path'") Commented Dec 7, 2020 at 20:27

1 Answer 1

1

Don't use os.system for precisely this reason. Use the subprocess module instead.

import subprocess

question1 = input('What is the input file': )
subprocess.run(['/programfilepath', '-i', question1, '-x', 'asdf', '-o', '/output path'])
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.