Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to run C program and use its results in SageMath automatically?

I have a program in SageMath in which I need to use some results obtained from a C program. Let me explain it in more detail.

In Sage, I define file1 to be some file. Then I use the following


to write results in file1.

Then I run a C program to get ./a.out file. Then I run the ./a.out file (it uses results in file1 computed above) and save the result to another file file2.

Then I run the following to get the final result.


Is there some way to compute c2 automatically in SageMath? That is, do not need to run ./a.out separately. Instead, to run ./a.out by using some command in Sage automatically.

I am asking this is because I have a lot of data and I need to run ./a.out manually each time. The file ./a.out is the same each time, but it uses different file1 and gives different values in file2 each time.

Thank you very much.