<?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: Sample Shell Script with Menu in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712337#M96043</link>
    <description>Hi Mark:&lt;BR /&gt;&lt;BR /&gt;In lieu of declaring '/usr/bin/sh' in the user's initial program field in '/etc/passwd' substitute your shell (menu) script.  Then make the script look something like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;PATH=/usr/sbin:/usr/bin:/sbin&lt;BR /&gt;trap '' INT QUIT&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;  clear&lt;BR /&gt;  echo "Host: $(hostname). $(date "+%a %x %X %Z"). [ Operations Utilities ]"&lt;BR /&gt;  echo "\n  &amp;gt;&amp;gt;&amp;gt; Enter &amp;lt; 0 &amp;gt; to Logout"&lt;BR /&gt;  echo "\n  &amp;gt;&amp;gt;&amp;gt; Enter &amp;lt; l &amp;gt; to ..."&lt;BR /&gt;  echo "\n  &amp;gt;&amp;gt;&amp;gt; Enter &amp;lt; 2 &amp;gt; to ..."&lt;BR /&gt;  echo "\n*---&amp;gt; \c"&lt;BR /&gt;&lt;BR /&gt;  read   CHOICE&lt;BR /&gt;  case ${CHOICE} in&lt;BR /&gt;    0 ) exit 0&lt;BR /&gt;        ;;&lt;BR /&gt;    1 ) ${HOME}/script/abc&lt;BR /&gt;        ;;&lt;BR /&gt;    2 ) ${HOME}/script/xyz&lt;BR /&gt;        ;;&lt;BR /&gt;   "") continue&lt;BR /&gt;        ;;&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 18 Jan 2006 12:57:32 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-01-18T12:57:32Z</dc:date>
    <item>
      <title>Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712335#M96041</link>
      <description>Hi to All&lt;BR /&gt;&lt;BR /&gt;Ok maybe I am going to be chastised to not doing more research but it never hurts to ask I guess.&lt;BR /&gt;&lt;BR /&gt;I need to make a basic script which when run gives the user a list say of ten things whereby they can select a number and then it performs that operation.&lt;BR /&gt;&lt;BR /&gt;Does anybody know where I could find a template script to kick me off. Say something silly with a few options.&lt;BR /&gt;&lt;BR /&gt;Thanks so much in advance!&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Mark</description>
      <pubDate>Wed, 18 Jan 2006 12:44:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712335#M96041</guid>
      <dc:creator>Mark Treen_1</dc:creator>
      <dc:date>2006-01-18T12:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712336#M96042</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;See attached.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Wed, 18 Jan 2006 12:53:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712336#M96042</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-01-18T12:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712337#M96043</link>
      <description>Hi Mark:&lt;BR /&gt;&lt;BR /&gt;In lieu of declaring '/usr/bin/sh' in the user's initial program field in '/etc/passwd' substitute your shell (menu) script.  Then make the script look something like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;PATH=/usr/sbin:/usr/bin:/sbin&lt;BR /&gt;trap '' INT QUIT&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;  clear&lt;BR /&gt;  echo "Host: $(hostname). $(date "+%a %x %X %Z"). [ Operations Utilities ]"&lt;BR /&gt;  echo "\n  &amp;gt;&amp;gt;&amp;gt; Enter &amp;lt; 0 &amp;gt; to Logout"&lt;BR /&gt;  echo "\n  &amp;gt;&amp;gt;&amp;gt; Enter &amp;lt; l &amp;gt; to ..."&lt;BR /&gt;  echo "\n  &amp;gt;&amp;gt;&amp;gt; Enter &amp;lt; 2 &amp;gt; to ..."&lt;BR /&gt;  echo "\n*---&amp;gt; \c"&lt;BR /&gt;&lt;BR /&gt;  read   CHOICE&lt;BR /&gt;  case ${CHOICE} in&lt;BR /&gt;    0 ) exit 0&lt;BR /&gt;        ;;&lt;BR /&gt;    1 ) ${HOME}/script/abc&lt;BR /&gt;        ;;&lt;BR /&gt;    2 ) ${HOME}/script/xyz&lt;BR /&gt;        ;;&lt;BR /&gt;   "") continue&lt;BR /&gt;        ;;&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 18 Jan 2006 12:57:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712337#M96043</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-01-18T12:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712338#M96044</link>
      <description>Hey!&lt;BR /&gt;&lt;BR /&gt;I have had a similar question, have a look at this thread, there are a lot of sample scripts&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=984784" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=984784&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Wed, 18 Jan 2006 12:59:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712338#M96044</guid>
      <dc:creator>Oviwan</dc:creator>
      <dc:date>2006-01-18T12:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712339#M96045</link>
      <description>Here's one I have used.&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Wed, 18 Jan 2006 13:27:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712339#M96045</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-01-18T13:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712340#M96046</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;Attached is a template for a menu driven shell script. It can be used as a framework for building upon. Enjoy and hope it helps!!!&lt;BR /&gt;&lt;BR /&gt;:)</description>
      <pubDate>Wed, 18 Jan 2006 14:48:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712340#M96046</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-01-18T14:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712341#M96047</link>
      <description>I used this in one of my scripts. I hope it helps&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;clear&lt;BR /&gt;writeyx () {&lt;BR /&gt;tput cup $2 $3&lt;BR /&gt;echo "$1"&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Starting_messages () {&lt;BR /&gt;clear&lt;BR /&gt; writeyx "Please, give as many input as posible." 8 20&lt;BR /&gt; writeyx "USERNAME=" 10 20&lt;BR /&gt; writeyx "EVENTNAME=" 12 20&lt;BR /&gt; writeyx "SYSCALL=" 14 20&lt;BR /&gt; writeyx "FROM mmddhhmm[yy]" 16 20&lt;BR /&gt; writeyx "TO mmddhhmm[yy]=" 18 20&lt;BR /&gt; tput smso; writeyx "" 40 0&lt;BR /&gt; read user; writeyx "$user" 10 40&lt;BR /&gt; tput smso; writeyx "" 40 0&lt;BR /&gt; read event; writeyx "$event" 12 40&lt;BR /&gt; tput smso; writeyx "" 40 0&lt;BR /&gt; read syscall; writeyx "$syscall" 14 40&lt;BR /&gt; tput smso; writeyx "" 40 0&lt;BR /&gt; read from_date; writeyx "$from_date" 16 40&lt;BR /&gt; tput smso; writeyx "" 40 0&lt;BR /&gt; read to_date; writeyx "$to_date" 18 40&lt;BR /&gt; tput rmso&lt;BR /&gt;&lt;BR /&gt; if [[ $user != "" ]]; then&lt;BR /&gt;     OPTIONS="-u $user" &lt;BR /&gt; fi&lt;BR /&gt; if [[ $event != '' ]]; then &lt;BR /&gt;     OPTIONS="$OPTIONS -e $event "&lt;BR /&gt; fi&lt;BR /&gt; if [[ $syscall != "" ]]; then&lt;BR /&gt;     OPTIONS="$OPTIONS -c $syscall" &lt;BR /&gt; fi&lt;BR /&gt; if [[ $from_date != '' ]]; then &lt;BR /&gt;     OPTIONS="$OPTIONS -t $from_date "&lt;BR /&gt; fi&lt;BR /&gt; if [[ $to_date != '' ]]; then &lt;BR /&gt;     OPTIONS="$OPTIONS -s $to_date "&lt;BR /&gt; fi&lt;BR /&gt;       tput cup 41 6&lt;BR /&gt;       print -n "Requesting to know if $user ran command that called $syscall btw $FD to $TD"&lt;BR /&gt;       print -n "Press y/n/q"&lt;BR /&gt;&lt;BR /&gt;       read ans&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;from_date () {&lt;BR /&gt; dates=$from_date&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Jan 2006 15:41:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712341#M96047</guid>
      <dc:creator>Lolupee</dc:creator>
      <dc:date>2006-01-18T15:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712342#M96048</link>
      <description>/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use diagnostics;&lt;BR /&gt;S_="MENU";&lt;BR /&gt;write;&lt;BR /&gt;print "Enter Choice:";&lt;BR /&gt;my $choice=&lt;STDIN&gt;;&lt;BR /&gt;&lt;BR /&gt;if($choice=~/[Aa]) {&lt;BR /&gt;    print "You picked option A\n";&lt;BR /&gt;}elsif{$choice=~/[Ll} {&lt;BR /&gt;     exit(0);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;format MENU&lt;BR /&gt;============================================&lt;BR /&gt;a. do something&lt;BR /&gt;b. do something else&lt;BR /&gt;l. exit&lt;BR /&gt;===========================================&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;/STDIN&gt;</description>
      <pubDate>Wed, 18 Jan 2006 17:14:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712342#M96048</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2006-01-18T17:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712343#M96049</link>
      <description>To piggy back off of Mark's question, how do you get a menu driven script to execute a simple command, for example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo "\n &amp;gt;&amp;gt;&amp;gt; Enter &lt;A&gt; for the current time"&lt;BR /&gt;read choice&lt;BR /&gt;case ${choice} in&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If the user selects &lt;/A&gt;&lt;A&gt;, how would you write this in the script to execute the time command?&lt;BR /&gt;&lt;BR /&gt;Thank all!&lt;/A&gt;</description>
      <pubDate>Tue, 15 May 2007 19:16:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712343#M96049</guid>
      <dc:creator>OMGPLSHELP</dc:creator>
      <dc:date>2007-05-15T19:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sample Shell Script with Menu</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712344#M96050</link>
      <description>&lt;!--!*#--&gt;&amp;gt;OMGPLSHELP:  how do you get a menu driven script to execute a simple command&lt;BR /&gt;&lt;BR /&gt;I was going to say you use the select builtin.  And if you look at Pete's example, it does that.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;echo "&amp;gt;&amp;gt;&amp;gt; Enter &lt;A&gt; for the current time"&lt;BR /&gt;&amp;gt;read choice&lt;BR /&gt;&amp;gt;case ${choice} in&lt;BR /&gt;&lt;BR /&gt;One could do that.  For my select example:&lt;BR /&gt;&lt;BR /&gt;echo "Select the compare mode:"&lt;BR /&gt;select DT in "-r" "-b" "-a"; do&lt;BR /&gt;   break&lt;BR /&gt;done&lt;BR /&gt;if [ "$DT" = "" ]; then&lt;BR /&gt;   DT="-r"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This prints:&lt;BR /&gt;Select the compare mode:&lt;BR /&gt;1) -r&lt;BR /&gt;2) -b&lt;BR /&gt;3) -a&lt;BR /&gt;#?&lt;BR /&gt;&lt;BR /&gt;The user types in a number, 1 to 3.&lt;BR /&gt;The logic above says if an invalid number is typed, set it to the "-r" choice.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;If the user selects &lt;/A&gt;&lt;A&gt;, how would you write this in the script to execute the time command?&lt;BR /&gt;&lt;BR /&gt;For your case:&lt;BR /&gt;case ${choice} in&lt;BR /&gt;"&lt;/A&gt;&lt;A&gt;") date ;;&lt;BR /&gt;... # other choices&lt;BR /&gt;*) echo "invalid choice: ${choice}" ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/A&gt;</description>
      <pubDate>Tue, 15 May 2007 21:38:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sample-shell-script-with-menu/m-p/3712344#M96050</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-05-15T21:38:19Z</dc:date>
    </item>
  </channel>
</rss>

