Google Answers Logo
View Question
 
Q: Autorun / autolaunch of CDROM on Linux. ( No Answer,   2 Comments )
Question  
Subject: Autorun / autolaunch of CDROM on Linux.
Category: Computers > Operating Systems
Asked by: webharmonics-ga
List Price: $60.00
Posted: 14 Jun 2005 05:15 PDT
Expires: 14 Jul 2005 05:15 PDT
Question ID: 533137
Need a solution for autorun / autolaunch for CDROMs on Linux boxes. 
Broadest compatibily would be great - but we need a solution that is
reliable for Red Hat Linux boxes at minimum.

The files we want to autolaunch are html files that are located on the CD.

How reliable is this solution?  Will the solution work with the
default settings on Red Hat Linux boxes?  How broad is the
compatibility of this solution?

Clarification of Question by webharmonics-ga on 16 Jun 2005 13:04 PDT
Thanks so much for your repsonse.  Here is more clarifiation -

RH 8 or higher is what we really need to cover.  But as I said, the
broader the compatibility the better!

Aside from the script, another issue I have a question about - if I
make the autorun file executable will these permissions be preserved
on the CD?  Does the format of the CD matter?  ISO9660 ok?

Have you successfully tested the below script launching an html file
on inserting a CD?
Answer  
There is no answer at this time.

Comments  
Subject: Re: Autorun / autolaunch of CDROM on Linux.
From: beakergeek724-ga on 14 Jun 2005 17:43 PDT
 
A little more backgroound info would be helpful.  What version of Red
Hat?  Which other Linux distributions?

Gnome and KDE both have their own way of automatcly mounting CDs and
running "/cdrompath/autorun" if it exists.  Both of these features
are, to the best of my knowlege, enabled by default in Red Hat. 
Autorun (autorun.sourceforge.net) came with Red Hat 6.1 and Red Hat
first placed an autorun file on the installation CD with Red Hat 7.1. 
Debian includes MagicDev, which does this same thing, though I did not
see what the earliest version of Debian to include this was.

Htmlview was introduced in RedHat 8.0 to allow users to select a
default HTML viewer and email client, thereby relieving other
applications of the duty of knowing or guessing which client to use. 
I am uncertain at this time as to which other Linux distributions
provide this program.

I wrote this script, which tries to be as general as possible, to try
to meet your needs.  I can add to or change it for you if you like.

#!/bin/sh

# Determine path to cdrom
cdrompath=$(echo $0 |sed 's/\/autorun//')

# Try to locate a suitable HTML viewer.
htmlviewspec=`/usr/bin/which htmlview` 2> /dev/null
firefoxspec=`/usr/bin/which firefox` 2> /dev/null
mozillaspec=`/usr/bin/which mozilla` 2> /dev/null
operaspec=`/usr/bin/wich opera` 2> /dev/null
konquerorspec=`/usr/bin/which konqueror 2> /dev/null

# Determine if KDE is running
pidofkwm=`pidof kwm`

# Set htmlviewer to the full path and file name of the web browser to use
# Prefered browsers should be before depreciated ones to give them priority
if [ ! $htmlviewspec = "" ] ; then
   htmlviewer=$htmlviewspec
elif [ ! $pidofkwm = "" ] ; then
   if [ ! $konquerorspec = "" ] ; then
      htmlviewer=$konquerorspec
   fi
elif [ ! $firefoxspec = "" ] ; then
   htmlviewer=$firefoxspec
elif [ ! $mozillaspec = "" ] ; then
   htmlviewer=$mozillaspec
elif [ ! $operaspec = "" ] ; then
   htmlviewer=$operaspec
fi

# Open an HTML file from CD using selected web browser
$htmlviewer $cdrompath/some_folder/some_file.html
Subject: Re: Clarification of Question by webharmonics-ga
From: beakergeek724-ga on 22 Jun 2005 11:29 PDT
 
Sorry about the delay in getting back to you.

I corrected a missing a backquote on line 14 and now the script works
as it should on my computer, running Fedora Core 3.  None of this code
uses OS specific functions and it should run on any computer that will
automaticly run the autorun script and has the following: sh (in FC3
sh is a symlink to bash, which works fine), which, sed, pidof (not
vital, only used to see if KDE is running, but should come with every
Linux distribution), and a web browser (Firefox, Mozilla, Opera,
Konqueror, or htmlview configured to run an installed browser, the
scrip can easily be rewritten to look for other browsers too).

It sounds like you are burning from Linux, because you asked if the
executable permissions will be preserved so, yes, mkisofs (or any
utility, like Gtoaster that, uses mkisofs) will preserve your file
permissions.  All of the files I coppied to CD and to my flash drive
from Windows have had the executeable permission set (turned on) when
I have examined them in Linux so, if you are burning from Windows,
this will probably not be a problem.

I was unable to test UDF, so I am unable to provide you with any first
hand information there, but I don't know why you would go out of your
way to create a UDF disc when ISO9660 is generally the default for
most software.

If you are initially saving this script in Windows you will want to
convert it before you try running it because Windows ends each line
with a carriage return and a line feed, whereas Linux uses only a line
feed and this may cause the script to fail.  This can be accomplished
using the following command:

dos2unix -c ascii autorun.txt

As for the script itself, here it is, as tested.

#!/bin/sh

# Determine path to cdrom
cdrompath=$(echo $0 |sed 's/\/autorun//')

# Try to locate a suitable HTML viewer.
htmlviewspec=`/usr/bin/which htmlview` 2> /dev/null
firefoxspec=`/usr/bin/which firefox` 2> /dev/null
mozillaspec=`/usr/bin/which mozilla` 2> /dev/null
operaspec=`/usr/bin/wich opera` 2> /dev/null
konquerorspec=`/usr/bin/which konqueror` 2> /dev/null

# Determine if KDE is running
pidofkwm=`/sbin/pidof kwm`

# Set htmlviewer to the full path and file name of the web browser to use
# Prefered browsers should be before depreciated ones to give them priority
if [ ! $htmlviewspec = "" ] ; then
   htmlviewer=$htmlviewspec
elif [ ! $pidofkwm = "" ] ; then
   if [ ! $konquerorspec = "" ] ; then
      htmlviewer=$konquerorspec
   fi
elif [ ! $firefoxspec = "" ] ; then
   htmlviewer=$firefoxspec
elif [ ! $mozillaspec = "" ] ; then
   htmlviewer=$mozillaspec
elif [ ! $operaspec = "" ] ; then
   htmlviewer=$operaspec
fi

# Open an HTML file from CD using selected web browser
exec $htmlviewer $cdrompath/some_folder/some_file.html

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy