Bash Script and Settings for Running MYM for DOS on Linux

Running DOS versions of MYM on Linux
Post Reply
asajay
Posts: 62
Joined: Thu Mar 01, 2007 7:25 pm

Bash Script and Settings for Running MYM for DOS on Linux

Post by asajay »

The following Bash shell script creates a lock file so that only one instance of MYM can be opened at one time.

Why do we need this?

If you open MYM more than once, you are opening the database more than once and the program doesn't really know who is in charge. You could inadvertently make changes in one instance, close and then make changes in the other and it will corrupt the database. Even if you don't make any changes in the second instance, it could still corrupt the database when you close the application. This is a bad thing and causes a lot of frustration on the part of the user. This script protects that from happening.

The Script

This script was created after a similar method for Windows, originally created by Dave K. on the cnet Forums. The script checks for the presence of a lock file and if found, the script exits immediately. If the lock file is not found, the script creates it, and then runs DOSEMU. An autoexec.bat entry in DOSEMU starts MYM. See the posting on DOSEMU and setup.

Using VI, emacs, or any other text editor in Linux, copy the following:

Code: Select all

#!/bin/bash

#
# Script to allow only one instance of Managing Your Money to run at any
# one time on Linux.
# NOTE:  This is for single users.  This does not cover multiple users
# who may be accessing the same file.
#

#
# We put the lock file in the users home directory by default, $HOME
# which should be a variable already set in the users environment.
# to check, run "set" (without the quotes) at a command prompt and check
# for the HOME variable and make sure it points to the users home.
#

#
# Check to see if a lock file already exists,
# Exit if exits
# Else create lock file and run application
#

# Check for lock file
if test -a "$HOME/mymlock.flg" ; then
        exit
else
        touch $HOME/mymlock.flg
fi

dosemu -4X

# Remove lock file after MYM exits
rm $HOME/mymlock.flg
Once saved, change the permissions of the file to be executable:

<your prompt># chmod +x <your mymfilescriptname.

Creating an Icon for MYM

You can place the script almost anywhere and run it either from the command line or create an icon on your Linux Desktop. For ease of use, I suggest creating an icon on your desktop. The following instructions are for KDE:

- Right-click anywhere on your desktop.
- Select "Create New" > "Link to Application"
- Change the name to MYM or Managing Your Money, and add the version if you like.
- Change the icon to one that suits your taste and draws your eye to the application MYM.
- In the application tab, enter a description and comment if you wish.
- Enter the command by browsing to the location of the script you created earlier.
- In the working path, put the path to the DOSEMU dos being used. In my case it's /home/<username>/dosemu/freedos
- Click on Advanced and un-select "Launch Feedback."
- Click OK, then OK again.
- Test the new icon.

At this point MYM should open only once; any subsequent click on the icon should result in absolutely nothing happening.

Creating an icon for the Gnome desktop should be similar in nature though the details may be different.

Happy Managing in Linux,
Asa Jay
Forum Sponsor and Prime Moderator.

Post Reply