[maemo-developers] root from scripts Re: [maemo-developers] Is there a convenient way of switching between usb/bluetooth/wifi networking?
From: Frantisek Dufka dufkaf at seznam.czDate: Fri Sep 22 11:39:09 EEST 2006
- Previous message: [maemo-developers] Is there a convenient way of switching between usb/bluetooth/wifi networking?
- Next message: root from scripts Re: [maemo-developers] Is there a convenient way of switching between usb/bluetooth/wifi networking?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Morgan wrote:
> Of course the challenge is doing
> something with root.
If you have r&d mode enabled there is easy trick for shell scripts.
#!/bin/sh
# use gainroot to become root and relaunch itself
if [ `id -u` != 0 ] ; then
#if not already root, call itself as root
sudo gainroot <<EOF
$0 $*
EOF
exit
fi
# real script follows
The only problem is that with this stdin is not original console used
for launching. If this is needed there is workaround like adding
TTY=`tty`
before 'sudo gainroot <<EOF' line and using
$0 <$TTY $*
But there should be also check if tty returns 'not a tty'.
Frantisek
- Previous message: [maemo-developers] Is there a convenient way of switching between usb/bluetooth/wifi networking?
- Next message: root from scripts Re: [maemo-developers] Is there a convenient way of switching between usb/bluetooth/wifi networking?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
