1

I've got a simple script which runs a windows program through wine with an argument (ie. myScript.sh = ~/some/path/someProgram.exe someArg). When I run it from its own directory it works fine:

cd ~/some/path
./myScript.sh

However if I try to run it from somewhere else:

cd /home/me
./some/path/myScript.sh

Because of How to execute script in different directory? I thought this might work:

/home/me/some/path/myScript.sh

but the script (or the resulting wine call) fails if I do anything other than run the script from the directory. Is there anyway to call the script from elsewhere without breaking it?

P.S. This isn't a permissions issue: the script has executable permission on for all users.

9
  • Create a bin dir in /home/$USER and add that to your path then put it in bin now you can run it from anywhere Dec 2, 2017 at 19:08
  • 1
    Please edit your original question to show the script. It will help us help you. Otherwise we can only guess what is the problem.
    – sudodus
    Dec 2, 2017 at 19:09
  • I think the link you gave should have an answer! Did you add cd $(dirname $0) as suggested in one the answers there? Dec 2, 2017 at 19:10
  • @sudodus I shared the script in my question: some/path/someProgram.exe someArgis the entire script (although as I mentioned someProgram.exe gets run by wine), and the specific executable/argument is irrelevant to the issue (plus I rather doubt you're familiar with it anyway). Dec 2, 2017 at 19:25
  • 1
    Would it help to use a full path to the exe file or maybe in some argument?
    – sudodus
    Dec 2, 2017 at 19:39

1 Answer 1

2

I found a sloppy solution: I made things working by explicitly calling cd inside my script and then using wine explicitly to run the executable:

cd ~/some/path
wine someProgram.exe someArg

However it seems like there should be some way to make that work without explicitly calling cd, and I'll accept any answer that explains it. I won't accept this one since it doesn't truly answer my original question (because it does the cd it's not really running things "from elsewhere").

1
  • 1
    I think this solution is OK. You need not feel that it is sloppy ;-)
    – sudodus
    Dec 2, 2017 at 19:42

Your Answer

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

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