Without any DE or even X, I want to use ./my.exe to run mono my.exe, like it works with python scripts.
3 Answers
Bash has no such feature. Zsh does, you can set up aliases based on extensions:
alias -s exe=mono
This would only work in an interactive shell, however, not when a program invokes another.
Under Linux, you can set up execution of foreign binaries through the binfmt_misc mechanism; see Rolf Bjarne Kvinge. Good Linux distributions set this up automatically as part of the mono runtime package.
If you can't use binfmt_misc because you don't have root permissions, you'll have to settle for wrapper scripts.
#!/bin/sh
exec /path/to/mono "$0.exe" "$@"
Put the wrapper script in the same directory as the .exe file, with the same name without .exe.
- 807,993
- 194
- 1,674
- 2,175
It is possible:
Become root and turn on the binfmt module in your kernel with this command (you may want to add this command to your /etc/rc.local boot script, so that it will be executed on boot):
modprobe binfmtAdd the line below to your /etc/fstab file:
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc noneThen, have your system run the following command on boot:
echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/registerBe sure to mark your .exe files as executable in the filesystem as well:
chmod +x myprogram.exe
(from here: http://mono-project.com/Guide)
Note that this is not the recommended way, read the above mentioned Guide page and also the page on how to do application deployment for mono applications.
- 226
- 1
- 3
-
I see, truly I better make loader for each .exe I need – cnd Sep 06 '12 at 08:28
You might be able to embed the file inside a bash script using the following guide http://www.linuxjournal.com/content/add-binary-payload-your-shell-scripts
- 2,467
- 22
- 26