Hello All
I am want to run a command "Merge -i file1.txt -i file2.txt -o out.txt" using python script. Here Merge is a exe file located in different path and file1, file2 are input to the exe file and out is output file. Can anyone suggest me out to run this command in python script.
Thank you

I do this so frequently that I created a bit of library code. It's so short that it should need no explanation.

import subprocess

def execCmd(cmd=""):
    return subprocess.check_output(cmd, shell=True).decode().splitlines()

if __name__ == "__main__":
    for line in execCmd(r"dir d:\temp"):
        print(line)

For your specific example just use

cmd = "Merge -i file1.txt -i file2.txt -o out.txt" 

and the return value will be whatever lines of output would be written to the console if you ran it from the shell manually.

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.