15

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

system("dir/WAV2RAW.exe")
Melebius
  • 11,121
  • 8
  • 50
  • 77
ASAD
  • 479
  • 2
  • 5
  • 13
  • 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 08:56
  • 7
    Could be a slight case of the XY-problem (https://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: https://stackoverflow.com/questions/9383576/how-to-convert-16bit-wav-to-raw-audio – Manawyrm 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. – David Foerster Jan 24 '18 at 12:48

2 Answers2

35

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
N0rbert
  • 97,162
  • 34
  • 239
  • 423
  • 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](https://askubuntu.com/revisions/999295/2) 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](https://askubuntu.com/a/776010/113421) 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 06 '22 at 16:58
  • No, wine-stable [is 3.0.1](https://packages.ubuntu.com/search?suite=all&section=all&arch=any&keywords=wine-stable&searchon=names), so old; while wine is synonym of wine-development thus [5.0.3](https://packages.ubuntu.com/search?suite=all&exact=1&searchon=names&keywords=wine) is newer. – N0rbert Jan 06 '22 at 17:04
4

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

Charles Green
  • 20,952
  • 21
  • 60
  • 92