Is it possible to run a .exe file in Ubuntu in a script? For example a simple Matlab code like this:

  • 1
    If the .exe file is a windows executeable, you can't run it directly in Ubuntu (or other Linux's). Either you should install Wine and run it through that, or find a utility in Ubuntu that does the same as the windows one.
    – Soren A
    Jan 24 '18 at 8:56
  • 7
    Could be a slight case of the XY-problem (meta.stackexchange.com/questions/66377/what-is-the-xy-problem)... If you want to convert a wav-file to raw PCM data for processing in Matlab, you could use a linux-tool like sox instead: stackoverflow.com/questions/9383576/… Jan 24 '18 at 10:57
  • Is WAV2RAW.exe the only EXE program you want to run, or do you have several other DOS / Windows / .NET programs?
    – dcorking
    Jan 24 '18 at 11:25
  • 1
    I'm relatively sure that Matlab (and its open-source clone Octave) have native functions to parse WAVE headers and data as well as to write raw PCM data since I used them in the past. Those would obviate the need for an external conversion application unless the PCM data doesn't fit into main memory. Jan 24 '18 at 12:48

I think you should use Wine.

sudo apt-get install wine
wine dir/WAV2RAW.exe

Or Mono if you know that exe is .NET application:

sudo apt install mono-runtime
mono dir/WAV2RAW.exe
  • 5
    You don't need to chmod. Besides that, it's worth noting that not all software runs under wine. YMMV.
    – el.pescado
    Jan 24 '18 at 10:35
  • 1
    You seem to have added the chmod line according to my comment. However, I think it is only necessary if you want to run the .exe file directly, i.e. without prepending wine to the command line – like OP wants to. I haven’t tested it with Wine but it behaves this way with .NET exe files (mono my.exe or chmod +x my.exe && ./my.exe) or even shell scripts (sh script.sh or chmod +x script.sh && ./script.sh).
    – Melebius
    Jan 24 '18 at 10:36
  • 5
    @Melebius that works because Wine registers itself in binfmts when installed from the official Ubuntu package.
    – Ruslan
    Jan 24 '18 at 10:38
  • Recent Ubuntu editions seem to want sudo apt-get install wine-stable
    – LondonRob
    Jan 6 at 16:58
  • No, wine-stable is 3.0.1, so old; while wine is synonym of wine-development thus 5.0.3 is newer.
    – N0rbert
    Jan 6 at 17:04

As mentioned in the comments this may be an XY problem

You could use 'sox' to convert from raw to wav file types:

sudo apt install sox

will install the program, then

sox --type raw <infile> --type wav <outfile>

would perform a simple conversion from the raw to wav formats

Not the answer you're looking for? Browse other questions tagged or ask your own question.