Results 1 to 10 of 10

Thread: expert-level file-type association

  1. #1
    Join Date
    Aug 2015
    Beans
    8

    Question expert-level file-type association

    I have installed Wine1.7. I realize that if I chmod an EXE file as executable, and run it in a terminal using "./test.exe", it will automatically invoke wine to load the program and run it.
    1. How is this kind of file association achieved? I changed /usr/bin/wine into some other executable program (call it ProgramA), now when I run "./test.exe", it says "cannot execute binary file: Exec format error", however, ProgramA is not executed at all. So obviously, this kind of file association is done inside /usr/bin/wine itself.

    2. I want to run every EXE file using "LC_ALL=zh_CN.UTF-8 wine" instead of just "wine". How to do it?
    The following solution does not work:
    mv /usr/bin/wine /usr/bin/wine-orig
    echo "LC_ALL=zh_CN.UTF-8 /usr/bin/wine-orig $*" >/usr/bin/wine
    I thought shell-level or MINE-level file association is such that whenever an EXE file is to be executed, /usr/bin/wine is launched. However, it is not that simple.
    Apparently, changing the content of the binary executable /usr/bin/wine breaks the EXE file association.
    Last edited by xuancong84; August 25th, 2015 at 07:05 AM.

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    19,757
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: expert-level file-type association

    It isn't wine - it is bash.
    I would just set this environment varialbe inside my ~/.bashrc file:
    Code:
    export LC_ALL=zh_CN.UTF-8
    This link explains how to modify ..
    https://stackoverflow.com/questions/...etion-in-shell explains more.

    BTW - Linux doesn't use extensions. It uses the "magic number" at the beginning of files to determine a file type. Use the "file" program to query the type of any file. Bash has a completion-module that will use extensions to help complete commands using a {tab}. Don't think that is related to this at all. This package may not be installed on all systems.

    For example:
    Code:
    $ file /bin/bash 
    /bin/bash: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=4ead65aeca4e9f1eabf3a0d63eb1f96c225b25fd, stripped
    This system is running 3.16.0-45-generic kernel on Ubuntu 14.04.2 LTS.

    Having the background will be useful to setting expectations.

  3. #3
    Join Date
    Aug 2015
    Beans
    8

    Re: expert-level file-type association

    I do know the export command.
    I have "export LC_ALL=en_US.UTF-8" in my .bashrc file. I need to keep "export LC_ALL=en_US.UTF-8" so that other program can function properly.
    In other words, I would like to implement a wine wrapper which particularly deals with EXE files. And I want my wrapper to be called when EXE files are executed.

    Your solution is what I already know and does not solve my problem.

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    19,757
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: expert-level file-type association

    Did you actually read the linked solution?

  5. #5
    Join Date
    Aug 2015
    Beans
    8

    Re: expert-level file-type association

    Yes, of course, I have read your link.

    Unfortunately, your link is talking about something else. And that one has nothing to do with the wine executable itself. See the difference:
    1. For bash completion, if I modify /usr/bin/wine, "wine <tab><tab>" still lists only .exe files, because it's handled by the "bash completion package", and changing the wine executable does not touch the "bash completion package setting" at all.
    2. For my question, if I modify /usr/bin/wine, "./ProgramA.exe" will no longer invoke wine, and you get "cannot execute binary file: Exec format error".

    In other words, the .exe file association is dynamically determined by /usr/bin/wine, not by bash or any other package, i.e.:
    1. if /usr/bin/wine is the installed version, then "./ProgramA.exe" == "wine ProgramA.exe", /usr/bin/wine is invoked
    2. if /usr/bin/wine is my modified version, then "./ProgramA.exe" != "wine ProgramA.exe", /usr/bin/wine is not invoked; since ProgramA.exe is not a Linux binary executable, you get "Exec format error"

    Do you understand my question better now? That is why I call this thread "expert-level".
    Last edited by xuancong84; August 6th, 2015 at 02:58 AM.

  6. #6
    Join Date
    Feb 2015
    Location
    United States
    Beans
    Hidden!
    Distro
    Ubuntu Studio

    Re: expert-level file-type association

    It just seems like you are trying to rename wine. How is that supposed to do anything other than mess up the system? Of course wine can't run if you rename (and thus disable) parts that it needs to run. Right?

  7. #7
    Join Date
    Aug 2015
    Beans
    8

    Re: expert-level file-type association

    Quote Originally Posted by yoshi2 View Post
    It just seems like you are trying to rename wine. How is that supposed to do anything other than mess up the system? Of course wine can't run if you rename (and thus disable) parts that it needs to run. Right?
    Nope. I did not mess up the system because I just changed /usr/bin/wine into a shell script which calls "LC_ALL=zh_CN.UTF-8 <original-wine>":
    mv /usr/bin/wine /usr/bin/wine-orig
    echo "LC_ALL=zh_CN.UTF-8 /usr/bin/wine-orig $*" >/usr/bin/wine

    Thus, if the system is as before, which simply use /usr/bin/wine to execute every EXE file, everything should work out correctly.

  8. #8
    Join Date
    Jun 2007
    Beans
    17,299

    Re: expert-level file-type association

    You could probably approach from the file manager side, set your mime association for .exe to a custom .desktop that sets the env & opens wine on the target/arg1 file. Either directly in the .desktop on Exec= line or if need be via a script that is called from the Exec= line.

    Or set up a diversion in /usr/bin where wine is moved to a new name (wine.real) & /usr/bin/wine is a script that sets env & calls wine.real
    (I used to to that a long time ago with a couple of apps for some forgotten reason & manner, if I can find the thread(s) about will link as I remember there were 3 files involved to do this.. (orig., script, link or something like that.

    Or do both to cover both FM & cli uses if both are possible, wine isn't used here so can't say..
    Last edited by mc4man; August 24th, 2015 at 09:52 AM. Reason: link

  9. #9
    Join Date
    Aug 2015
    Beans
    8

    Re: expert-level file-type association

    Quote Originally Posted by mc4man View Post
    You could probably approach from the file manager side, set your mime association for .exe to a custom .desktop that sets the env & opens wine on the target/arg1 file. Either directly in the .desktop on Exec= line or if need be via a script that is called from the Exec= line.
    You haven't understood my question correctly. Please re-read my post and every reply before you think you can answer.

    Quote Originally Posted by mc4man View Post
    Or set up a diversion in /usr/bin where wine is moved to a new name (wine.real) & /usr/bin/wine is a script that sets env & calls wine.real
    Exactly what I have tried in reply #7, it doesn't work.

  10. #10
    Join Date
    Feb 2015
    Location
    United States
    Beans
    Hidden!
    Distro
    Ubuntu Studio

    Re: expert-level file-type association

    why are you chmodding EXEs? EXE's aren't linux executables, so chmodding them for execution isn't likely to result in much of anything?
    i really don't understand how this is all "expert". wine works OK, seems like you are confusing it and puzzled why it doesn't work as intended.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •