0

so here is the code I have so far and I am good to change it if its better to go a different way.


import os

d = "testinput"
os.system("python3 download.py")

Once this is ran below is printed.

-Enter name of submission to download:
here is where id like the variable d to be inputted for me but having issues finding a way to do it. I am sure its simple but its not clicking just yet. Any help would be appreciated.

I have tried os.system("python3 download.py < d") But this gave me an error. sh: testinput: No such file or directory

James
  • 32,991
  • 4
  • 47
  • 70
  • Does this answer your question? [How do I pass a string into subprocess.Popen (using the stdin argument)?](https://stackoverflow.com/questions/163542/how-do-i-pass-a-string-into-subprocess-popen-using-the-stdin-argument) – Askold Ilvento Jan 15 '21 at 21:30

1 Answers1

0

You need to use d = input() if you want the user to input the value at runtime.

If you want to run a system command with that input, you need to add it to the string you are passing to os.system().

d = input()
os.system(f"something something {d}")
effprime
  • 578
  • 3
  • 10
  • No I am wanting the variable to be automatically inputted there once that other script is started. I will be having many different inputs there that come in. This script is going to kick off in a docker and no user input will be provided, at least from command line. – Bluice25 Jan 15 '21 at 21:46
  • Then you just need to pass the variable into `os.system()` with the help of string formatting (`f"text"`) – effprime Jan 15 '21 at 21:54