I'm writing a Python program that uses other software I use the subprocess.popen
By the order was able to pass. I am facing a new problem: I need to include as many files as two files and use it as an input for external program. The command line looks like this:
extersoftware --fq --f & lt; (Cat fileA_1 fileB_1) & lt; (Cat fileA_2 fileB_2)
I can not use shell = true
because other commands have to pass me in variables, such as - fq
. (They are not limited to the F - this is just one example)
A possible solution is to create the middle file, this is what I have tried to do:
File_1 = ['cat', 'fileA_1', 'fileB_1'] p1 = popan (file_1, standout = pipe) p2 = popan (['>
error message me Found:
Code> OSError: [Aran 2] No such file or directory What part was I wrong? />
It would be better if there is no middle file for this reason, I I'm looking at the designated pipe, I do not think it is silent.
I have seen many questions which have been answered, how are they all different from my question for me.Thanks for your help.
The way the handle handles then the command will open We can do the same thing in Python: For example: <
and <..)
/ Dev / fd / n where N is the input end of the pipe file descriptor ( Try Unj to <(true)
). / dev / fd / n
, and the OS will cause a duplicate of that legacy Read the end of the pipe.
Import subprocess import OS # Open a pipe and run a command that writes at the end of the input Input_fd, output_fd = Os.pipe () subprocess.Popen (["cat", "foo.txt", "bar.txt"], shell = false, stdout = output_fd) os.close (output_fd); # Run a command that reads end using proc = subprocess.Popen (["wc", "/ dev / fd /" + str (input_fd)), / dev / fd / * to shell, shell = False , Stdout = subprocess .ppe) # Print out the command of that command proc.communicate () [0]
$ cat Foo.txt Hello $ cat bar .txt world $ wc & lt; (Cat foo.txt bar.txt) 2 2 12 / dev / fd / 63 $ python test.py 2 12 / dev / fd / 4
Comments
Post a Comment