[syslinux] OT: Question on running command from boot menu

Michael D. Setzer II mikes at kuentos.guam.net
Thu Jan 1 03:33:54 PST 2009

I have a project that disk imaging from a cd using isolinux and a dialog gui 
system, but some users want to setup systems to run automatically. Some 
can download the development kit, and built an image with a modified script, 
but others don't have the skills or resources. I've come up with a system that 
seems to work with both the isolinux.cfg or menu.lst with grub4dos and I 
believe regular grub as well.  The system adds a run=" " option to cmdline.

A simple option could just be run="fg4l ipaddress" which would download a 
script from ftp and run it. 

Below is a more complex option that runs multi-line command. Using \n didn't 
work, so came up with a method to use CR as a marker, and replacing it.

Single line from menu.lst used by grub4dos, but same works with 

kernel /linux/bz27.10 root=/dev/ram0 rw ramdisk_size=65536 run="e2fsck 
/dev/hda2CRmount /dev/hda2 /mnt/localCRlzop -d -c /mnt/local/d8new.lzo | 
ntfsclone -r --overwrite /dev/hda1 - CRumount /mnt/localCRsleep 5CRreboot"

The cd will the load the kernel, and the above line is in the /proc/cmdline file.
The user g4l automatically logs on, and this is at the beginning of the 
g4lmenu script to process the cmdline if anything in the run=" " exists.

### 12/31/20008 added to allow running command from grub
### add run="command line" to the grub line
### creates /tmp/runcmd to stop running twice.
### added sed CR filtering to allow multi-line commands
### run="command1CRcommand2CRcommand3"
if [ ! -s "/tmp/runcmd" ] ; then
  cat /proc/cmdline | grep run | cut -d\"  -f 2 | sed -e 's/CR/\n/g' >/tmp/runcmd;
  if [ -s /tmp/runcmd ] ; then
    sh /tmp/runcmd
    sleep 10;

The above system does seem to work in my limited test, and it would be 
rather simple to modify the isolinux.cfg or other using isomaster or similar 
windows program.

Wondering if I am missing anything in this, or warnings that might need to be 


  Michael D. Setzer II -  Computer Science Instructor      
  Guam Community College  Computer Center                  
  mailto:mikes at kuentos.guam.net                            
  mailto:msetzerii at gmail.com
  Guam - Where America's Day Begins                        

http://setiathome.berkeley.edu (Original)
Number of Seti Units Returned:  19,471
Processing time:  32 years, 290 days, 12 hours, 58 minutes
(Total Hours: 287,489)

SETI 7,122,242.9956 | EINSTEIN 2,218,390.1109 | ROSETTA 

More information about the Syslinux mailing list