Mark
Mark

Reputation: 7576

Running a command with os.system(A) produces different output then running A in shell

I have a hex to binary converter that I am using in a Python script...

os.system("./HexToBinary " + str(sys.argv[1]) + "_hex " + str(sys.argv[1]) + "_binary")

If I run my python script on file A_hex, it produces file A_binary.

But if I run this command directly in the command-line, on file AA_hex it produces AA_binary. But A_binary and AA_binary differ!

diff example_python example_shell 
Binary files example_python and example_shell differ

The version produced by the python os.system call is missing a chunk of data from the end. It seems that it just gets cut off.

I'm kinda stumped. Any thoughts?

Upvotes: 0

Views: 468

Answers (1)

Anycorn
Anycorn

Reputation: 51465

I dont know if it is needed, but try wait, http://docs.python.org/library/os.html#os.wait

also, check the output of system, it may help tell you if something is wrong

Upvotes: 1

Related Questions