Moving file and starting application

For both game and non game related issues in using or running Linux.
Locked
User avatar
Netrom.dk
Developer
Posts: 1106
Joined: Mon May 12, 2003 5:53 am
Location: Denmark

Moving file and starting application

Post 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).

User avatar
shield
Developer
Posts: 783
Joined: Thu Feb 09, 2006 6:48 am
Location: Cambridge, UK
Contact:

Post 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.
Kord - The Brawler

cely
PKer
Posts: 1024
Joined: Thu May 06, 2004 4:09 am
Location: The Full Beard Tavern

Post 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.
cely
NS4 Server Admin
NS5 Developer (retired)

User avatar
Netrom.dk
Developer
Posts: 1106
Joined: Mon May 12, 2003 5:53 am
Location: Denmark

Post 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.

Binkyuk
Absentee Ballot Dev
Posts: 1012
Joined: Wed Mar 09, 2005 6:01 pm
Location: Cambridge, UK

Post 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.

User avatar
Netrom.dk
Developer
Posts: 1106
Joined: Mon May 12, 2003 5:53 am
Location: Denmark

Post 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 :oops:

Jaroo
Noob
Posts: 3
Joined: Tue Nov 21, 2006 6:44 am
Location: Netherlands

Post 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

Locked

Return to “General Linux Support”