List running services, corresponding package name and status.

Hi,

I am trying to list down list of running services, corresponding package name and status on HP-UX box. The output will be a CSV in a fashion:- Service Name, Package Name, Status.

While working on Linux centos, I used chkconfig to do the same. Below was the snippet:-

for i in `chkconfig --list | awk '{ print $1}'`; do

status=`/sbin/service $i status`
packagename=`rpm -qf /etc/init.d/$i`

if echo "$status" |grep -q running; then
echo $i","$packagename",""Running" > "$HOME/MyLog/running_services_${ip}_${tdaydatefile}.csv"

else
if echo "$status" |grep -q stopped; then
echo $i","$packagename",""Stopped" > "$HOME/MyLog/running_services_${ip}_${tdaydatefile}.csv"
fi

fi
done

Now, chkconfig doesn't exist on HP-UX. Is there a way I can retrieve the similar output on HP-UX? Any help related to this is appreciated.

Thanks.

Hi Happy83,

Welcome to forums, kindly use code tags as per forum rules for commands/codes/inputs while posting. For your request:

HPUX does not have a similar utility.You would need to create your own init scripts. You can start with a copy of 1 of the init scripts and then make the necessary changes. Then make the additions to them. You can use /sbin/init.d/template file to create your own init scripts.

NOTE: you can go though the forum rules in following link too.

Thanks,
R. Singh

Here is a chkconfig emulation for HP-UX.
Installed software packages are listed with

swlist

More swlist options are explained in

man swlist

As an aside, your chkconfig script will not work on modern systemd-based OSes such as RHEL7