Page 1 of 1
Moving file and starting application
Posted: Wed Nov 29, 2006 8:34 am
by Netrom.dk
I finally sat down and got my first windows program setup using wine.
However to get it to work I need to keep copying one file from my cd to the folder where the program is installed.
So far I've done this manually, and then used the "run application" command to start the program afterwards using the 'wine [application path]/application' command.
How can I set it up so it copies the file from the cd to the application folder each time I want to start the program? In windows I would proberly have done it via a batch file, is there something similar I can do in Linux (well ofcouse there is, but I'm completely green with Linux still).
Posted: Wed Nov 29, 2006 9:07 am
by shield
Yup their is, basicly you need to write a shell scipt. Their are quite a few different languages you can do this in. I'd do it in bash.
http://tldp.org/LDP/abs/html/ as it's quite common for batch file type stuff. However you could use other scripts (can use perl if you want).
You probaly using a bash command line, so use bash script would mean your putting the commands you a script that you would usally type at the command prompt. Bit like MS-DOS command prompt/batch files.
Posted: Wed Nov 29, 2006 10:42 am
by cely
Create a text file in your /home/netrom/bin directory, technically it doesn't matter what you name it, but the normal naming convention for bash or any other shell scripts is filename.sh
Put this text in your filename.sh:
Code: Select all
#!/bin/bash
cp /full/path/to/sourcefile /full/path/to/destinationfile
wine /full/path/to/exefile
Set the executable bit on filename.sh with your GUI or on the CLI like this:
Code: Select all
chmod +x /home/netrom/bin/filename.sh
Now all you have to do is run filename.sh or you can create a shortcut to it from your desktop/menu. I hope this helps.
Posted: Wed Nov 29, 2006 5:16 pm
by Netrom.dk
Thanks cely it works great.... Its nice to have succes.
However the script seems to run for a long time after the application is opened. When I run the script it takes 5 seconds to open the application and the files it needs to acces (its Folio View and needs to open up most of the danish law). However after that the script stays around on the process bar and mouse cursor looks like its trying to open something too for another 25 sec. So the script doesn't terminate untill 30 seconds after it was started.
I put in 'exit' in the end to hope that would help but no change in that.
Posted: Wed Nov 29, 2006 6:23 pm
by Binkyuk
try this:
Code: Select all
#!/bin/bash
cp /full/path/to/sourcefile /full/path/to/destinationfile
wine /full/path/to/exefile </dev/null >/dev/null 2>/dev/null &
the extra & starts wine as a background task and the shell script will continue.
the input redirector will detach wine from the shell and allow it to close, the output redirectors will prevent wine from getting a SIGPIPE if it tries to output.
hopefully that'll do it (no machine to test it on right now), otherwise look up the nohup command.
Posted: Thu Nov 30, 2006 9:07 am
by Netrom.dk
Oops apperently I misdiagnosed my problem, it only happens when I use the link from the desktop to the script and not if I run the script directly from its folder.
Tried both with and with our you additions Bink with no difference.
edit: It proberly should be noted that I use KDE and Debian
edit #2: Disabling "lauch feedback" of the shortcut did the trick
Posted: Fri Dec 01, 2006 5:23 am
by Jaroo
It usually helps to make the script execute the program from its own path like this:
Code: Select all
#!/bin/bash
cd /path/to/program/
cp /media/cdrom/sourcefile .
wine program.exe &
The dot at the end of the cp command means the sourcefile is copied to the current path (/path/to/program/). If it has to be copied to a subdirectory you can replace it with ./subdirectory
You can place this script in any path you want. Personally I keep programscripts in ~/.loaders