Create a file called GetHistoryFiles.ksh. Or what ever you would like.
Enter the fillowing into it
#!/usr/bin/ksh93 # This script is (pwn) by OZUS.LLC and written by Lance Lenz # function qping { # Check to see if the node is responding ping -c1 -w1 $1 1>/dev/null 2>&1 && PING=yes || PING=no } # Read in the Server List for nodeName in odcapmdm00 odcapmdm01 odcapmdm03 odcapmdm04 odcaamdm01 odcaamdm02 do # skip over server names commented out $nodeName == #* && continue # test to see if the host is managed for manIt in -man -pers _man do manNode=$nodeName$manIt qping $manNode if [ "$PING" = "yes" ] then break fi done if [ "$PING" = "no" ] # just try node name then manNode=$nodeName qping $manNode fi if [ "$PING" = "yes" ] then echo $nodeName $manNode # for i in `ssh root@$manNode ls /var/History |awk '{print $1}'` do integer CNT=`ssh root@$manNode fuser -f /var/History/${i} 2>&1 | awk '$2 != "" { print $1 }'|cut -d: -f1|wc -l` if [ ${CNT} -eq 0 ];then #echo "scp root@$manNode:/var/History/${i} /utlpd02/History/Test/${i}" scp root@$manNode:/var/History/${i} /utlpd02/History/MDMS/${i} ssh root@$manNode rm /var/History/${i} else echo "This file is open ${i}" fi done else echo $PING $manNode fi done