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

Michael D. Setzer II mikes at kuentos.guam.net
Thu Jan 1 15:53:13 PST 2009


On 1 Jan 2009 at 12:51, H. Peter Anvin wrote:

Date sent:      	Thu, 01 Jan 2009 12:51:27 -0800
From:           	"H. Peter Anvin" <hpa at zytor.com>
To:             	For discussion of Syslinux and tftp-hpa 
<syslinux at zytor.com>
Subject:        	Re: [syslinux] OT: Question on running command from 
boot menu
Send reply to:  	For discussion of Syslinux and tftp-hpa 
<syslinux at zytor.com>
	<mailto:syslinux-
request at zytor.com?subject=unsubscribe>
	<mailto:syslinux-request at zytor.com?subject=subscribe>

First, Thanks for the reply.

> Michael D. Setzer II wrote:
> > 
> > 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.
> > 
> 
> In most cases you can just use ; or perhaps better &&.  There usually
> isn't much reason to have multiline commands in Unix.
> 

I had originally tried the && and it wasn't working with the e2fsck command 
and was coming up with help for the command. Then tried \&\& and it also 
didn't work. At that time, I was just moving the cutting the command to a 
string, and running the string,  so perhaps going to a file would work. Not an 
expert on this. 


> > Single line from menu.lst used by grub4dos, but same works with
> > isolinux.cfg.
> > 
> > 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;
> >   fi
> > fi
> 
> 
> Perhaps a cleaner version:
> 
> sed -r -e 's/^(|.*[[:space:]])run="(.*)"([[:space:]].*|)$/\2/e' \
>  < /proc/cmdline
> 

I'm really going to have to look at that, some things I'm not familiar with.

> > 
> > 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 included.
> > 
> 
> Overall, it should work, I believe.  There are always issues (neither
> your versions or mine handle commands that need embedded double
> quotes, for example).

I did think of the quote issue, and in the same way that I used CR to 
represent \n, something like QQ could be used to represent \" in 
replacement.

Thanks again.



> 
> -- 
> H. Peter Anvin, Intel Open Source Technology Center
> I work for Intel.  I don't speak on their behalf.
> 
> _______________________________________________
> Syslinux mailing list
> Submissions to Syslinux at zytor.com
> Unsubscribe or set options at:
> http://www.zytor.com/mailman/listinfo/syslinux
> Please do not send private replies to mailing list traffic.
> 


+----------------------------------------------------------+
  Michael D. Setzer II -  Computer Science Instructor      
  Guam Community College  Computer Center                  
  mailto:mikes at kuentos.guam.net                            
  mailto:msetzerii at gmail.com
  http://www.guam.net/home/mikes
  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)

BOINC at HOME CREDITS
SETI 7,122,242.9956 | EINSTEIN 2,218,390.1109 | ROSETTA 
736,835.9944




More information about the Syslinux mailing list