0

I know it's a very general question but I am open for different options.

Let me clarify what my codes do:

  • The C++ code produces multiple .png files as output as follows

    ./Debug/mycpp input1path input2path output parameter1 parameter2

  • The python code takes those png files to do image processing and returns them as png as well

    mypython.py inputpath outputpath

What I want to do:
* To create an "executor code" that runs and links those 2 codes
* The only criterion is that 'the executor code' should work on Ubuntu

Any suggestions will be appreciated.

Additional notes:
* I don't want to call c++ in python, I just want to create a 3rd code (e.g. shell script) that calls c++ first then calls python after c++ has finished it's task.

uguros
  • 356
  • 2
  • 6
  • 19
  • 2
    So .. a simple shell script. – Botje May 20 '20 at 08:19
  • 1
    Does this answer your question? [Calling Python script from C++ and using its output](https://stackoverflow.com/questions/16962430/calling-python-script-from-c-and-using-its-output) – Roy2511 May 20 '20 at 08:22

2 Answers2

1

Python is perfect for such scripts, it has a complete support for such scripts.

You should look at subprocess and os modules for the complete command set for it.

Kerek
  • 1,106
  • 1
  • 8
  • 18
0

Compile the c++scipt.cpp to an executable c++script. Then add the following in a shell script (script.sh)

#!/bin/bash
./c++script
python pythonscript.py

Then run with

$ sh script.sh

or (the first command just makes it executable)

$ chmod +x script.sh
$ ./script.sh
Pani
  • 1,317
  • 1
  • 14
  • 20
  • 1
    Many thanks. I used Python's "os library" in Python so that I can run my C++ code in the Python itself. – uguros Jun 10 '20 at 22:09