#!/bin/csh

# work process quick view: check SM50, save to timestamped filename
# Conditions:
# - Run as sidadm or root
# - Directory ~sidadm/sm50 must exist and writable
# - Run regularly from cron or manually

# Sample crontab entry:
# 01,04,07,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58  * * * * su - sbxadm -c /home/sbxadm/sm50.csh  # temp - sap sm50 work process info

# Parameters:
set SID=SBX
set usr=sbxadm
set pro=SBX_DVEBMGS00_erpsbxci01
# Be sure to also check the shell path on the first line /bin/csh
# as some unixes require /usr/bin/csh instead

# Code begins.
rm -f ~$usr/sm50/latest 2>/dev/null
cd /sapmnt/$SID/profile && \
  /usr/sap/$SID/SYS/exe/run/dpmon -i -s l  pf=$pro > ~$usr/sm50/latest

if ( ! -z ~$usr/sm50/latest ) then
   set newdate=`date "+%Y%m%d-%H%M"`
   cd ~$usr/sm50 && mv latest sm50-$SID-$newdate      # sm50-SBX-20080312-1739
endif

exit 0
