#################################################################################################
# .profile_sub_util		(c) R. H. Reepe 12th December 1996	Version 1.0		#
#################################################################################################
# 961212 RHR Genesis
# 970410 CAH Function added to create list of printers know to server
# 

#===================================================================================
s_is_cron()			# (c) R. H. Reepe. Returns 1 (cron) or 0 (not cron)
#===================================================================================
{
	tty | grep -c not
}

#===================================================================================
s_header()			# (c) R. H. Reepe. Creates a Program Header
#===================================================================================
# Arg_1 [SCRIPT_NAME]
{
	head -4 ${1:-$0} | tail -3
}

#===================================================================================
s_debug_text()			# (c) R. H. Reepe. Returns $@ parameter in DEBUG
#===================================================================================
# Arg_n = [STRING]
{
	if [ "${DEBUG:-on}" = "on" ]
	then
		/usr/5bin/echo "$@"
	fi
}

#===================================================================================
s_debug_exec()			# (c) R. H. Reepe. Executes $@ parameter in DEBUG
#===================================================================================
# Arg_n = [STRING]
{
	if [ "${DEBUG:-on}" = "on" ]
	then
		$@
	fi
}

#===================================================================================
s_hash()			# (c) R. H. Reepe. Remembers locations of commands
#===================================================================================
{
	hash touch basename wc head bc expr grep ls tail rm cut sort dirname
}

#===================================================================================
s_pid()			# (c) R. H. Reepe. Returns the PID of a COMMAND
#===================================================================================
# Arg_1 = COMMAND
{
	ps -ef | grep -v grep | grep $1 | /bin/nawk '{print($2)}'

}

#=============================================================================================
s_chain_host()			# (c) R. H. Reepe. Returns Next Host in Backup Chain
#=============================================================================================
{
	_count=`s_arg_count $REFERENCE_DBSERVER`
	_posn=`s_find_string $THISHOST $REFERENCE_DBSERVER`
	if [ $_posn -eq $_count ]
	then
		s_get_string 1 $REFERENCE_DBSERVER
	else
		_posn=`expr $_posn + 1`
		s_get_string $_posn $REFERENCE_DBSERVER
	fi
}

#=========================================================================================
s_printers()			# (c) R. H. Reepe. Returns list of printers known to host
#=========================================================================================
{
	lpstat -t | grep accept | /bin/nawk '{print($1)}'
}