#!/usr/bin/perl $name=snmpd; # List of stop states $stop = "0 1 2 3 4 5 6"; while(<>) { # Format is chkconfig: if (/chkconfig: (\S+) (\S+) (\S+)/) { $Sn = $2; $Kn = $3; if ($1 =~ /-/) { print "update-rc.d -n $name defaults $Sn $Kn\n" ; } else { # Print start-states, remove from stop-states list @start = split('',$1); map { $stop =~ s/$_ //; } @start; print "update-rc.d -n $name start $Sn @start . stop $Kn $stop .\n"; } } }