in reply to Service controller for Linux/Unix
I might suggest the following changes:
By using the multi-argument form of exec (or system for that matter), we don't have to worry about shell metacharacters mucking us up. This is probably reasonably safe to run set-uid or via sudo.my $service = shift; my ($action) = $0 =~ m![^/]+)$!; # corrected per reply $service =~ tr~/~~d; die "$service: No such service" unless -x "/etc/rc.d/init.d/$service" +&& -f _; exec("/etc/rc.d/init.d/$service", $action) or die "exec: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Service controller for Linux/Unix
by jjhorner (Hermit) on Feb 09, 2001 at 01:29 UTC | |
by Fastolfe (Vicar) on Feb 09, 2001 at 01:50 UTC |