I'm kind of new to Python and trying to figure something out. I am trying to write a quick script to do parameter testing for a C code that I've written.
The part that is getting to me is when I try to use subprocess.call in order to run my C code. The C code has one argument that is the name of a file that is opened within the code itself.
For example:
filename = myclass.path + myclass.inputname
subprocess.call(["./code", filename])
This will run the code, and it passes the correct filename, but the C code will not read in any of the information from the file at all. If I pass something like:
./code "filename"
to the shell, where "filename" is actually what is printed when I use the print command in python, it works just fine.
Just for the sake of being complete, here are the lines that are relevant within my C code:
in = fopen(argv[1], "r");
fscanf(in, "%s %d %d", variable1, &variable2, &variable3);
Any idea what is happening?
filenamelook like? It might be a special character issue or something. (You also might want to useos.path.joininstead ofmyclass.path + myclass.inputname).myclass.pathhave a trailing slash? You might need to add a slash between the path and the filename.