updated git and svn scripts
[xrzperl.git] / r-sudo
blobd34bf3d3f63df4c0e645379249c07f96fe2e21c6
1 #!/usr/bin/perl -w
2 ###APPNAME: r-sudo
3 ###APPAUTHOR: duel
4 ###APPDATE: Sat Mar 22 03:05:47 2008
5 ###APPVER: 0.1
6 ###APPDESC: A su front-end
7 ###APPUSAGE: username cmd
8 ###APPEXAMPLE: r-sudo xiaoranzzz firefox -P xiaoranzzz
9 ###APPOPTION:
10 use lib $ENV{XR_PERL_MODULE_DIR};
11 use strict;
12 use MyPlace::Script::Usage qw/help_even_empty/;
14 exit 0 if(help_even_empty($0,@ARGV));
17 my $U=shift;
18 my $CMD=shift;
20 if($U eq $ENV{USER}) {
21 exit exec($CMD,@ARGV);
24 my $DOER="gksu";
25 $DOER="su" unless(`which "$DOER"`);
27 if($DOER eq "su") {
28 my $LCMD=$CMD;
29 $LCMD = $LCMD . " \"" . join("\" \"",@ARGV) . "\"" if(@ARGV);
30 exec $DOER,"-c",$LCMD,$U;
32 else {
33 exec "gksu","--user",$U,"--message","Password of $U needed to run '$CMD @ARGV'","--",$CMD,@ARGV;