#my @command = ("su - $user -c id") #################################### #system ("su - $user"); #this Works# #################################### #system ("@command") == 0 or die "system @command failed: $?"; #exec ('su - $user -c $action') or print STDERR "couldn't exec foo: +$!"; #exec("/bin/su","-",$user,$action); #system ("su", "-", $user, "-c", "/bin/bash -c $action"); #system ("su - $user -c /bin/bash -c $action"); #system "sudo","su","-" => $user, -c => $action;
but each one fails!!
also i tried these modules, same result ..
use warnings; use diagnostics; use strict; use Shell::Source; use Shell; my $action="\'Anything\'"; my $user="RealUser"; my $sh = Shell->new; say "$user"; say "$action "; print $sh->sudo("su -l - $user --command $action");
I start to thinking if my Gentoo has problems , I'll try in another system...
btw I've checked for $user seems that is good, just before function.
thanks..In reply to Re^2: run shell command as another user
by ox1d0
in thread run shell command as another user
by ox1d0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |