Launch script for linux

This forum is aimed at user contributions, in the form of assets, side projects, code patches and similar.

Moderator: joepal

Launch script for linux

Postby joepal » Mon Mar 16, 2009 3:20 pm

At the moment makehuman expects to be run from the mh_phoenix directory, which is illustrated by the following error:

Code: Select all
joepal@joepalnx:~/Skrivbord$ mh_phoenix/MH_Phoenix
Traceback (most recent call last):
  File "<string>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'main.py'
Could not run main Python script

joepal@joepalnx:~/Skrivbord$


I see two solutions to this: 1. make the MH_Phoenix binary aware of the fact that it has been run from another directory, or 2. Add a wrapper script.

I've tinkered with the second solution. Save the following to a file called "mh.bash" in the "mh_phoenix" directory, and chmod it 755:

Code: Select all
#!/bin/bash

CURRDIR=`pwd`
MHDIR=`echo $0 | sed -e "s/\/mh\.bash$//"`

if [ -f MH_Phoenix ]
then
  echo "Found MH_Phoenix, no need to CD"
else
  echo "Need to CD to find MH_Phoenix"
  cd $MHDIR
fi

./MH_Phoenix &> /dev/null

cd $CURRDIR


This way you can run it from somewhere else with an absolute path, eg

Code: Select all
/usr/bin/local/mh_phoenix/mh.bash


and it will launch correctly.

The reason why this is interesting is because when adding a launcher in for example the ubuntu menu system, the current directory isn't changed to where the binary is, thus resulting in a launch failure. If instead referencing this script in the menus, the application will launch correctly.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4474
Joined: Wed Jun 04, 2008 11:20 am

Return to User contributions

Who is online

Users browsing this forum: No registered users and 1 guest