curl-users
curl script error
Date: Mon, 10 Dec 2007 16:20:10 -0800 (PST)
Hi,
Grr, I've been bit by the script bug. Just found out the hard way that
you can't use 'su -c' in a script if you are trying to grab it from a
webpage and run it. I get the error "standard in must be a tty". Need
this to work for end-users, any ideas or workarounds? Anyone see this
before ? Thanks in advance.
EXAMPLE:
[quickm@duvel Desktop]$ *curl http://somehost.com/reinstall_package.sh
|
bash*
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 4313 100 4313 0 0 36125 0 --:--:-- --:--:--
--:--:--
3234k
checking credentials ...
Please enter the Administrator (root) password.
*standard in must be a tty*
CODE :
# --- Check for 'Root' credentials
CMDLN_ARGS="$@" # Command line arguments for
this script
export CMDLN_ARGS
# Run this script as root if not already.
# if passed silent option, will exit on failure.
chk_root () {
temp_cond="$1"
if [ ! $( id -u ) -eq 0 ]; then
if [ "$temp_cond" != "silent" ] ;then
echo "Please enter the Administrator (root) password."
exec su -c "${0} ${CMDLN_ARGS}" # Call this prog as root
exit ${?} # sice we're 'execing'
above, we wont reach this exit
# unless something goes
wrong.
else
# the 'silent' option has been set - just exit.
echo "root privilages have not been met ."
exit 1
fi
fi
}
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
Received on 2007-12-11