Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
By the way, some may ask why I need to do this. The code above is ran as root, but due to the complexities of the calling application which I have no control over, the passwd command must be ran as the user actually changing his password. The code above is part of a larger program.#!/usr/bin/perl my $verbose=1; my $user=@ARGV[0]; my $passwd_cmd="/usr/bin/passwd"; my $su_cmd="/bin/su $user -c"; ####################################################### ####################################################### my $cmd=$su_cmd . $passwd_cmd . " $user"; print "command=$cmd\n" if $verbose; my $output=system($cmd); print "output=$output\n" if $verbose; exit $output;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capture output from command under su
by shmem (Chancellor) on May 05, 2007 at 19:38 UTC | |
|
Re: Capture output from command under su
by grep (Monsignor) on May 05, 2007 at 18:23 UTC |