<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help script MENU in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246348#M687435</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I dislike the 'select' statement for menus for the problem you have.  The 'select' parameter is set to null for non-matches leaving you limited control.&lt;BR /&gt;&lt;BR /&gt;You could handle invalid selections as a "break":&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;select thing in A B C&lt;BR /&gt;do&lt;BR /&gt;  echo "${thing} seen"&lt;BR /&gt;  [ -z "${thing}" ] &amp;amp;&amp;amp; { echo "BAD THING!"; break; }&lt;BR /&gt;done&lt;BR /&gt;echo "exiting"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 05 Aug 2008 12:32:35 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2008-08-05T12:32:35Z</dc:date>
    <item>
      <title>Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246347#M687433</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I using select in my script, but i would like to include an exit or quit in a option in menu.&lt;BR /&gt;&lt;BR /&gt;tput clear&lt;BR /&gt;export PATH=/usr/sbin:/usr/bin:/usr/contrib/bin:/opt/perl/bin:/opt/ignite/bin:&lt;BR /&gt;&lt;BR /&gt;clear&lt;BR /&gt;# Diretorio das imagens&lt;BR /&gt;export CAM1=/var/opt/ignite/recovery/archives/PJHPXC01&lt;BR /&gt;export IGN_LOG=/home/ignite&lt;BR /&gt;&lt;BR /&gt;echo&lt;BR /&gt;echo&lt;BR /&gt;echo&lt;BR /&gt;echo "Deseja verificar log de alguma imagem (y/n) ? \c"&lt;BR /&gt;read OPCAO&lt;BR /&gt;&lt;BR /&gt;if [ "$OPCAO" = "y" -o "$OPCAO" = "Y" ]&lt;BR /&gt;  then&lt;BR /&gt;   PS3='Qual das imagens acima deseja ver o log? '&lt;BR /&gt;   echo&lt;BR /&gt;   select file in $(ls -tr $IGN_LOG | grep logimage)&lt;BR /&gt;   do&lt;BR /&gt;     echo $file&lt;BR /&gt;     cat $IGN_LOG/$file | more&lt;BR /&gt;     break&lt;BR /&gt;   done&lt;BR /&gt;   exit 0&lt;BR /&gt;   echo "[ Enter ]"&lt;BR /&gt;   read&lt;BR /&gt;  echo&lt;BR /&gt;  echo "Tecle [Enter] para voltar ao MENU"&lt;BR /&gt;  read&lt;BR /&gt;else&lt;BR /&gt;  if [ "$OPCAO" = "n" -o "$OPCAO" = "N" ]&lt;BR /&gt;   then&lt;BR /&gt;     echo&lt;BR /&gt;     echo "[ Enter ]"&lt;BR /&gt;     read&lt;BR /&gt;     exit&lt;BR /&gt;else&lt;BR /&gt;  echo "Opcao Invalida"&lt;BR /&gt;  read&lt;BR /&gt;  exit&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;clear&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;WAIT&lt;BR /&gt;&lt;BR /&gt;Fernando.</description>
      <pubDate>Tue, 05 Aug 2008 12:05:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246347#M687433</guid>
      <dc:creator>Fernando Jose P de Souz</dc:creator>
      <dc:date>2008-08-05T12:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246348#M687435</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I dislike the 'select' statement for menus for the problem you have.  The 'select' parameter is set to null for non-matches leaving you limited control.&lt;BR /&gt;&lt;BR /&gt;You could handle invalid selections as a "break":&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;select thing in A B C&lt;BR /&gt;do&lt;BR /&gt;  echo "${thing} seen"&lt;BR /&gt;  [ -z "${thing}" ] &amp;amp;&amp;amp; { echo "BAD THING!"; break; }&lt;BR /&gt;done&lt;BR /&gt;echo "exiting"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Aug 2008 12:32:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246348#M687435</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-05T12:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246349#M687437</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I would suggest a different approach.  You appear to be offering a list of files for viewing.  You could build and display the list by writing the filenames, one per line, in a temporary file.  Then 'cat -n' the temporary file for the user.  This shows them a number and a filename.&lt;BR /&gt;&lt;BR /&gt;Read the user's selection; validate that the number selected is in range and 'cat' the filename associated with the number selected as recorded in the temporary file.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 05 Aug 2008 12:39:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246349#M687437</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-05T12:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246350#M687439</link>
      <description>&lt;!--!*#--&gt;&amp;gt;JRF: I would suggest a different approach.&lt;BR /&gt;&lt;BR /&gt;Why is this any better than select?&lt;BR /&gt;Fernando's select nicely gets the files and adds a number before each.  It validates the number and either re-prompts or returns an empty string.  (This is what's missing.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;iI would like to include an exit or quit in a option in menu.&lt;BR /&gt;&lt;BR /&gt;As JRF mentioned, you need to handle the empty string.  If you want to add more options, you just fiddle with the pipeline:&lt;BR /&gt;... $(ls -tr $IGN_LOG | grep logimage; echo exit quit)&lt;BR /&gt;&lt;BR /&gt;The user won't be able to type "exit" or "quit" but there will be a number for that option.&lt;BR /&gt;&lt;BR /&gt;If you want to see what the the user typed, you can use something like:&lt;BR /&gt;select ident in $(ls p* ; echo exit quit); do&lt;BR /&gt;   echo "Returned: $ident"&lt;BR /&gt;   if [ "$ident" = "" ]; then&lt;BR /&gt;      echo "Invalid: user typed: $REPLY"&lt;BR /&gt;      break&lt;BR /&gt;   fi&lt;BR /&gt;   case $ident in&lt;BR /&gt;   exit) exit ;;&lt;BR /&gt;   quit) break 2 ;;&lt;BR /&gt;   *) echo "other" ;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;echo "After select"</description>
      <pubDate>Wed, 06 Aug 2008 05:24:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246350#M687439</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-06T05:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246351#M687441</link>
      <description>Denis, ok.&lt;BR /&gt;&lt;BR /&gt;But when i choose other option, the output:&lt;BR /&gt;&lt;BR /&gt;^ZM-\^A^C^L^B`^C$^B$^CM-T^B^D^BM-x^BM-D^B^T^DM-4^CM-`^D^L^DM-^H^DM-`^CM-8^CP^BH^D`^BM-^L^D8&lt;BR /&gt;^Ch^E^T^E^D^C4^CM-^@^CM-^\^Bt^BM-(^B8^^P^F.cshrc_^P^F.login`^.profilea^P^E.exrcb^X^L.profile.oldc&lt;BR /&gt;^T&lt;BR /&gt;adm_ignited^X^Lcreate_imagee^\^Pverifica_montadof^\^O.verifica_imageg ^S.verifica_image.oldh^.formatai^temp.txtj^X&lt;BR /&gt;.create_imagek^P^C^BM-d.swp^\^Q.verifica_montadoq^X^N.verifica_logs^AM-r^X^LPJHPXC01.tar^AM-q^\^Qignite_backup.tar^A&lt;BR /&gt;Z^\^Oformat.crontab.^A]^\^Qlogimage.crontab.^AM-.^L^A1^A\,^_logimage.crontab.20080803-02:24^A[,^_logimage.crontab.20080803-02:25&lt;BR /&gt;^A`(^]format.crontab.20080803-08:49^Aa(^]format.crontab.20080803-08:50^Ag,^_logimage.crontab.20080804-10:39^A^,^_logimage.crontab.2008&lt;BR /&gt;0804-10:40^AM-^U$^X.verifica_logs.05-8-2008^AM-^V^P^Dquit^AM-"^ZM-l^Dexit&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My script changed: &lt;BR /&gt;tput clear&lt;BR /&gt;export PATH=/usr/sbin:/usr/bin:/usr/contrib/bin:/opt/perl/bin:/opt/ignite/bin:&lt;BR /&gt;&lt;BR /&gt;clear&lt;BR /&gt;# Diretorio das imagens&lt;BR /&gt;export CAM1=/var/opt/ignite/recovery/archives/PJHPXC01&lt;BR /&gt;export IGN_LOG=/home/ignite&lt;BR /&gt;&lt;BR /&gt;echo&lt;BR /&gt;echo&lt;BR /&gt;echo&lt;BR /&gt;echo "Deseja verificar log de alguma imagem (y/n) ? \c"&lt;BR /&gt;read OPCAO&lt;BR /&gt;&lt;BR /&gt;if [ "$OPCAO" = "y" -o "$OPCAO" = "Y" ]&lt;BR /&gt;  then&lt;BR /&gt;   PS3='Qual das imagens acima deseja ver o log? '&lt;BR /&gt;   file2=`ls -tr $IGN_LOG | grep logimage`&lt;BR /&gt;      select ident in $(ls -tr $IGN_LOG | grep logimage; echo exit); do&lt;BR /&gt;      #echo "Returned: `cat $IGN_LOG/$ident 2&amp;gt; /tmp/lixo.txt`" | more&lt;BR /&gt;      cat $IGN_LOG/$ident 2&amp;gt; /tmp/lixo.txt | more&lt;BR /&gt;      exit&lt;BR /&gt;      if [ "$ident" = "" ]; then&lt;BR /&gt;         echo "Opcao Invalida: $REPLY"&lt;BR /&gt;         break&lt;BR /&gt;      fi&lt;BR /&gt;      case $ident in&lt;BR /&gt;       exit) exit ;;&lt;BR /&gt;       *) echo "other" ;;&lt;BR /&gt;      esac&lt;BR /&gt;   done&lt;BR /&gt;      echo "Selecionar outra opcao"&lt;BR /&gt;      echo "Tecle [Enter] para voltar ao MENU"&lt;BR /&gt;      read&lt;BR /&gt;else&lt;BR /&gt;  if [ "$OPCAO" = "n" -o "$OPCAO" = "N" ]&lt;BR /&gt;   then&lt;BR /&gt;     echo&lt;BR /&gt;     echo "[ Enter ]"&lt;BR /&gt;     read&lt;BR /&gt;     exit&lt;BR /&gt;else&lt;BR /&gt;  echo "Opcao Invalida"&lt;BR /&gt;  read&lt;BR /&gt;  exit&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;clear&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Aug 2008 15:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246351#M687441</guid>
      <dc:creator>Fernando Jose P de Souz</dc:creator>
      <dc:date>2008-08-06T15:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246352#M687443</link>
      <description>Hi (again) Fernando:&lt;BR /&gt;&lt;BR /&gt;As I originally said, "The 'select' parameter is set to null for non-matches leaving you limited control".&lt;BR /&gt;&lt;BR /&gt;Now, Dennis offered a way to add the "quit" prompt by munging with the data in your pipe.  Nice touch, Dennis.&lt;BR /&gt;&lt;BR /&gt;But, as I said, non-matches leave you with an empty (undefined) argument.  Thus when you do:&lt;BR /&gt;&lt;BR /&gt;# cat $IGN_LOG/$ident 2&amp;gt; /tmp/lixo.txt | more&lt;BR /&gt;&lt;BR /&gt;...and the value of 'ident' is empty, you are really reading the *directory* leading to garbage output!&lt;BR /&gt;&lt;BR /&gt;Thus, at the least, move the check for an empty 'ident' ahead of the 'cat'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Aug 2008 16:19:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246352#M687443</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-06T16:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help script MENU</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246353#M687444</link>
      <description>&amp;gt;JRF: non-matches leave you with an empty (undefined) argument. &lt;BR /&gt;&lt;BR /&gt;Right.  As I mentioned, you can also check $REPLY for the actual invalid input.</description>
      <pubDate>Thu, 07 Aug 2008 01:14:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-script-menu/m-p/4246353#M687444</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-07T01:14:41Z</dc:date>
    </item>
  </channel>
</rss>

