Thread: why does this not work
i have been reading guide, think error or 2 in it.code:#!/bin/bash if [ "$(id -u)" != "0" ]; cd /home/cristian #test else echo "you must superuser run script" >&2 fi
hope some1 can help.
i found on web instead.
but know why #1 not work, if can tell me.code:cmdln_args="$@" # command line arguments script export cmdln_args # run script root if not already. chk_root () { if [ ! $( id -u ) -eq 0 ]; echo "please enter root's password." exec su -c "${0} ${cmdln_args}" # call prog root exit ${?} # sice we're 'execing' above, wont reach exit # unless goes wrong. fi } # call function on - or before script's main loop starts. chk_root
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk why does this not work
Ubuntu
Comments
Post a Comment