On Fri, Jun 14, 2002 at 11:15:31AM -0500, Derrick 'dman' Hudson wrote:
> On Fri, Jun 14, 2002 at 02:59:24PM +1000, James Cameron wrote:
> | The package I have made (which also adds a graphical shutdown image
> | using zgv) does this in the post-installation script ...
> | 
> | # change control/alt/delete sequence to halt rather than reboot
> | sed 's/shutdown -t1 -a -r now/shutdown -t1 -a -h now/' \
> | < /etc/inittab > /etc/inittab.dpkg.lenny-shutdown
> | mv /etc/inittab /etc/inittab.pre-lenny-shutdown
> | mv /etc/inittab.dpkg.lenny-shutdown /etc/inittab
> | telinit q
> | 
> | But I was hoping to find a more elegant solution.  ;-)
> 
> That's how you edit files from the shell :-).  If you try this :
>     sed '<sed script>' < file > file
> you'll end up with either
>     1)  an error from the shell, if 'noclobber' is set
>     2)  a clobbered file, because the open for writing is done before
>         the data is read
> 
> Thus a temp file is needed for the redirection to work as intended.

You can get around this using perl's -i switch:

  perl -pi -e 's/shutdown -t1 -a -r now/shutdown -t1 -a -h now/' /etc/inittab
  telinit q

(Or -i.pre-lenny-shutdown if you want to keep a backup as above.)

-- 
Colin Watson                                  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to