This is a discussion on Shell script within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi I am not sure if this is the right group, but I will try anyway. I would like ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi I am not sure if this is the right group, but I will try anyway. I would like to write a shell script. The purpose of the script is to select a printer and a document from a predefined list, and combine them to a qprt command. I need two menus one where you can select the printer or exit, and one where you can select the document or return to printer selection. Some of the documents consist of more than one file that should be send to the printer with a delay of around 7 sec. I am new to shell scripts, so any hints that can lead me to a solution is appreciated. Regards Tom |
| |||
| If you 'ping -c 1 1' and have a momentary outage, you will get notified. ping will return a failed code if > 50% of pings fail. So a better test would be 'ping -c 3'. If 2 out of 3 pings fail, then $? will be "1", else it will be "0". On some OSes, a packet size of "1" is illegal. BV |
| |||
| "Tom" <rs_underscorefilex@post9.tele.dk> wrote in message news:<40332074$0$283$edfadb0f@dread12.news.tele.dk >... > Hi > > > > I am not sure if this is the right group, but I will try anyway. > > I would like to write a shell script. > > The purpose of the script is to select a printer and a document from a > predefined list, and combine them to a qprt command. > > I need two menus one where you can select the printer or exit, and one where > you can select the document or return to printer selection. > > > > Some of the documents consist of more than one file that should be send to > the printer with a delay of around 7 sec. > > I am new to shell scripts, so any hints that can lead me to a solution is > appreciated. > > > > Regards Tom Here's a snip of code that will display a menu and build a selection list. This will be the core of your script with some modifications, of course to make multiple selections, like the print queue and then the reports you wish to send to the print queue you will probably use code similar to this snip twice. CT=0 for FILE in `ls *.iso` do CT=`expr $CT + 1` echo "$CT) $FILE" echo -n "$FILE " >> $HOME/imagelist done echo echo "select # of image to burn" read ITEM Note the second echo in the for loop builds a space delimited list of the values displayed on the menu, you will wish to take care not to exceed the limits of the display. The following command will take the selection read as $ITEM and cut the appropriate value from the space delimited list. SELECTED_ITEM=`cut -f $ITEM -d " " $HOME/imagelist` This should get you started. Good luck, have fun! |
| |||
| While stranded on the hard shoulder of the information super highway rs_underscorefilex@post9.tele.dk typed: > Hi > > > > I am not sure if this is the right group, but I will try anyway. > > I would like to write a shell script. > > The purpose of the script is to select a printer and a document from a > predefined list, and combine them to a qprt command. > > I need two menus one where you can select the printer or exit, and one where > you can select the document or return to printer selection. > > Some of the documents consist of more than one file that should be send to > the printer with a delay of around 7 sec. > > I am new to shell scripts, so any hints that can lead me to a solution is > appreciated. Here are two parts of a script I wrote on an AIX box to display a list of printers from which the users could then do various things to a selected printer. The first chunk builds a list of all the printers. The second chunk displays the list on the screen and allows for selection. (I can't give you the whole script for obvious reasons and YMMV) inx=0 # build list of printers /usr/bin/lsallq | sort | while read ITM do inx=`expr $inx + 1` OPTDSC[${inx}]="${ITM}" done let TOTAL=${inx} UDI=true # user data input while ( ${UDI} -eq true ) ; do let REC=1 let I=1 let J=1 let MIN=${REC} SCRN="${HDR}" # complete screen mask while (( ${I} <= ${lines} )) ; do if (( ${REC} <= ${TOTAL} )) ; then ITM=${OPTDSC[${REC}]} SCRN="${SCRN}\t${REC}\t${ITM}" let MAX=${REC} let REC=${REC}+1 let J=${J}+1 if [[ ${J} = 4 ]] ; # three printers per line then let J=1 SCRN="${SCRN}\n" let I=${I}+1 else if [[ ${#ITM} -lt 8 ]] ; # next tab stop then SCRN="${SCRN}\t" fi fi else SCRN="${SCRN}\n" # no more options let I=${I}+1 let REC=${REC}+1 fi done # Set which options are available and build the options message... PRMP="Enter printer number(s), or q(uit) :- " # Display screen mask and accept input data OK="" while [[ ${OK} = "" ]] ; do print -n "${SCRN}\n${rev}${MSG}${std}\n\n${PRMP}" read ans if [[ ${?} != 0 ]] ; then clear echo "\n\n${JOBNAME} - run aborted!" exit 0 fi MSG="" CMD="" case ${ans} in[*]) doone ;; q|Q) OK="true" UDI=false ;; *) doall ;; esac done done Good luck with your endevours -- Trog Woolley | trog at trogwoolley dot com (A Croweater back residing in Pommie Land with Linux) Isis Astarte Diana Hecate Demeter Kali Inanna |
| ||||
| If you need a pretty menu, I prefered smitty. First form a selector to select a printer. second a dialog asks if which document to be printed. Learn about the ODM programming, custom the ODM database, then you get the goal. I forget the URL, Search in IBM programming references. "Tom" <rs_underscorefilex@post9.tele.dk> wrote in message news:<40332074$0$283$edfadb0f@dread12.news.tele.dk >... > Hi > > > > I am not sure if this is the right group, but I will try anyway. > > I would like to write a shell script. > > The purpose of the script is to select a printer and a document from a > predefined list, and combine them to a qprt command. > > I need two menus one where you can select the printer or exit, and one where > you can select the document or return to printer selection. > > > > Some of the documents consist of more than one file that should be send to > the printer with a delay of around 7 sec. > > I am new to shell scripts, so any hints that can lead me to a solution is > appreciated. > > > > Regards Tom |