in reply to Re: su to root in a perlscript
in thread su to root in a perlscript
but i am not very content with it since this wont work under win32. and sooner or later it has to.sub rootMeAndDoStuff(){ my $rootID = getpwnam("root"); if (not ($rootID eq $<)){ print "U have to be root to do the following ...\n"; system "su -c $PartToDoAsRoot"; } }
update: there is in fact a way to do exactly the same under win32:
sub adminMe(){ my $adminID = 0; if (not ($adminID eq $<)){ print "U have to be an Administator to do this ...\n"; print "Give me a name of a local Administator:\n"; my $admin = <STDIN>; chomp $admin; my $hostname = hostname; system "runas /user:$hostname\\$admin \"cmd /K perl $whatToDoAsAdmin\""; } }
----
NaSe
:x
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: su to root in a perlscript
by crenz (Priest) on Aug 01, 2002 at 18:08 UTC |