[Tutor] Linux app question

Ewald Ertl ewald.ertl at hartter.com
Thu Aug 18 09:38:05 CEST 2005

Hi Alberto

Alberto Troiano wrote:
> Hey tutors....long time don't see...*grin*
> I have a question, I've made a web page in PHP and its going to run under 
> Linux Red Hat 9.0
> The page has scripts that has to be on a certain path off the system...I 
> have to make a CD to give the web page to my client and I made a script 
> using Python 2.2.2 so when he runs it, the data in the CD will be copied 
> automatically to the path where every script has to be
> My question is:
> Obviously I will have the cdrom in /mnt/cdrom and in order to run the 
> "installer" the user will have to type
> python /mnt/cdrom/installer.py
> 1.- Is there any way that the script can be started when he mounts the CDROM 
> with the command mount /mnt/cdrom?

Sorry, for this I have no clue what to do.

But it could also be possible that CDROM's are mounted, without the permission to
execute programms on that filesystem  ( mount ... -o noexec ). With this option
it is not possible to execute programs on that filesystem, but I don't know the
defaults on RedHat Linux 9.0.

> 2.- Is there any way that the script could be started by typing directly 
> ./installer instead of python installer.py?

When you name the installer.py simple installer, set the executeable-Right's and
insert the following line on the first one:

#!/usr/bin/env python

This will lookup the Interperter python on the system und run the File with this.

An other possible solution could be that, you create a Shell-Script which start's itself
the python-Process with the executeable-Rights set.

#!/usr/bin/env bash

dirName=`dirname $0`

PYTHON=`which python`

if [[ -z $PYTHON ]]; then
	echo " No Python-Interperter found"
	$PYTHON $dirName/installer.py

Here you can also insert some other error-checking.

HTH Ewald

More information about the Tutor mailing list