0

I’m trying to create a Python script that launches a C program that is located in the same folder and it must take the input and write out the output in the same folder. I tried to use the “subprocess.run()” method but my problem with it is that it only works if I execute the C file through WSL, but my main necessity is that I want to “zip” the folder and make it usable for other people as this is a small project I need to share with colleagues. Can somebody help?

Tried using Python subprocess.run() method but it obviously won’t work for other people as it works for me just because I have WSL installed

3
  • 1
    'if i execute the C file' – do you mean the C source file? If so, bad luck, you need to compile – if it is compiled already into an executable then it is actually irrelevant in which language it has been written... In the latter case subprocess.run() eventually is the right thing to do – but if you need WSL for then your programme has been compiled for linux – so it cannot run under windows natively. Recompile your programme then using a compiler for windows (e.g. MinGW, MSVC, ...). Commented Oct 18, 2023 at 9:14
  • 1
    Please note that you should always write a detailed question, giving other people a clear picture of what exactly you are trying to do, which environment you are using etc. Commented Oct 18, 2023 at 9:52
  • 1
    Based on your question, what I understood is that your executable file (complied C file) is not environment-friendly. And that's why you need additional support to run your file. My suggestion is to keep multiple executables based on the OS environment. And then, in your script, check the OS to select the respective executable to run. Please refer to the following link, which explains how to check the system OS on which the Python script is currently running. stackoverflow.com/questions/1325581/… Commented Oct 18, 2023 at 10:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.