I'm trying to write a script thats spawns a fortran program that needs std file input i.e. you would open it in bash with: ./program < input
How can I do this in python? I have tried the os.spawnl() and it spawns the process but the input does not work.
samush
0
Newbie Poster
Recommended Answers
Jump to PostSearch this forum or google for subprocess. It's the new de facto method of spawning processes. There's plenty of examples if you look.
Jump to PostThere should be a comma after PIPE (I'm guessing that this is a tuple), and then a communicate statement
proc2 = subprocess.Popen("/home/samush/Documents/kandidat_arbete/python/cr_to_fr/fortreaderc", shell=True, stdin = subprocess.PIPE,) proc2.communicate('\tstdin: to stdin\n')
All 8 Replies
jlm699
320
Veteran Poster
samush
0
Newbie Poster
woooee
814
Nearly a Posting Maven
samush
0
Newbie Poster
samush
0
Newbie Poster
jlm699
320
Veteran Poster
samush
0
Newbie Poster
woooee
814
Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.