× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.






Hello folks-

Thanks for all of the help and advice for the autostarting script for
lp5250d. It is now complete and running and I thought to send you all a
copy just in case anybody would need it too.

The basic idea is that it refers to a new file /etc/tn5250lp for a list of
printers to start. These printers must be properly defined in
/etc/tn5250rc. It might be possible to put lp5250d options in this file,
but I have not tested this.

I had to sleep the script 5 seconds for the restart case, so that our very
remote and somewhat loaded as/400 would have time to find that the writer
is no longer active and to shut it down before the new connection starts.
Without this sleep period, 50% of restarts would fail. If this still proves
to be a problem, I will consider modifying the script to check that the
daemon has actually started.

Thanks

Elmars


#!/bin/bash
#
# v.0.6 of a script to start, stop and restart preconfigured as/400
printers.
# this script to parses the  start, stop and restart
# options from the command line and based on this input acts on the
printers
# listed in /etc/tn5250lp. The printers in this list must be defined in
# /etc/tn5250rc. It should be possible to run this script either as an init
# script or from the commandline by any user.
#
# Usage:start: This will start any printers not already started. It will
test
#               for each printer's presence and if not found will start it.
#       stop:   This will stop all started printers
#       restart:This will stop all started printers and then will
#               start all listed printers.
#
# Initial code for single printer management provided by James Rich
# Adapted and modified for larger scale use by Elmars Ositis
# This script is free to use and modify without restriction.

case "$1" in

        start)
                exec 6<&0
                exec < /etc/tn5250lp
                while read printer
                do
                        PID=`ps ax|grep "lp5250d $printer"|egrep -v
grep|awk '{print $1}'`

                        if [ "$PID" ]; then
                                echo "lp5250d $printer is running with PID
${PID}"
                        else
                                echo "starting lp5250d $printer..."
                                lp5250d $printer
                        fi
                done
                exec 0<&6 6>&-
                ;;
        stop)

                exec 6<&0
                exec < /etc/tn5250lp
                while read printer
                do
                        PID=`ps ax|grep "lp5250d $printer"|egrep -v
grep|awk '{print $1}'`
                        if [ "$PID" ]; then
                                echo "stopping lp52250d $printer with PID
${PID}"
                                kill -9 $PID
                        else
                                echo "nothing to stop"
                        fi
                done
                exec 0<&6 6>&-
                ;;
        restart)
                exec 6<&0
                exec < /etc/tn5250lp
                while read printer
                do
                        PID=`ps ax|grep "lp5250d $printer"|egrep -v
grep|awk '{print $1}'`
                        if [ "$PID" ]; then
                                echo "stopping lp52250d $printer with PID
${PID}"
                                kill -9 $PID
                                echo "starting lp5250d $printer..."
#                                       the following delay is to allow a
remote as/400
#                                       to recover before starting the
writer again.
#                                       may need to increase delay for
loaded systems
                                sleep 5
                                lp5250d $printer
                        else
                                echo "starting lp5250d $printer..."
                                lp5250d $printer
                        fi
                done
                exec 0<&6 6>&-
                ;;
        *)
                echo "Usage: test {start|stop|restart}"
                exit 1
                ;;
esac

exit 0


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.