Equivalent output in HP-UX. Already have script ready for Linux Centos

181 Views Asked by At

I am new to HP-UX and never worked on Ksh/Csh. Have been working with bash on Linux for quite some time now. I have below few code snippets to extract system information from Linux centos and dump to a CSV as output.

Would appreciate if someone can help me with equivalent command/output on HP-UX as none of these works on HP-UX.

1) To output all installed packages and version on Linux Centos:

rpm -qa --qf "%{name},%{version}\n" > $HOME/MyLog/installed_packages_.csv

2) To output all running processes, PID and memory on Linux Centos:

top -b -n 1 | awk 'NR>7 {print date","ip","$12,","$1,","$10}' >> $HOME/MyLog/running_process.csv

3) To output all running services, package name and status on Linux Centos:

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 $tdydate","$ip","$i","$packagename",""Running" >> "$HOME/MyLog/running_services_${ip}_${tdaydatefile}.csv"

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

fi
done

I am looking for an equivalent of the above scripts on HP-UX. Any help here would be appreciated.

1

There are 1 best solutions below

0
On

HP-UX is UNIX with a few command changes.

To manipulate packages, you can use one of the following swinstall, swlist. I'd check the man pages to give you clues beyond this. You'll have to experiment as the outputs will not be identical to Linux of course.

If you google you will find a HPUX porting site where your favorite opensource software that may be missing from HP-UX is found. One of these is top another one of my favorites is lsof.

As long as you use basic /bin/sh constructs between the systems your scripting should port fairly easily ... but you will have to change. sh or ksh is NOT bash...thus keeping things simple when scripting between different systems is definitely required.