<?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: Writing a Menu-Driven Script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000733#M96054</link>
    <description>&lt;P&gt;JRF has the command being entered by the user. Is this what you want? (The user could enter "rm -rf /". )-:&lt;BR /&gt;&lt;BR /&gt;In my reply to your same question in:&lt;BR /&gt;&lt;A target="_blank" href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=993074"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=993074&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/Languages-and-Scripting/Sample-Shell-Script-with-Menu/m-p/3712343"&gt;http://h30499.www3.hp.com/t5/Languages-and-Scripting/Sample-Shell-Script-with-Menu/m-p/3712343&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I had:&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 "+ Enter 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;echo "Select the compare mode:"&lt;BR /&gt;select DT in "-r" "-b" "-a"; do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;BR /&gt;done&lt;BR /&gt;if [ "$DT" = "" ]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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, 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;"") date ;;&lt;BR /&gt;... # other choices&lt;BR /&gt;*) echo "invalid choice: ${choice}" ;;&lt;BR /&gt;esac﻿&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2011 04:19:47 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2011-10-03T04:19:47Z</dc:date>
    <item>
      <title>Writing a Menu-Driven Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000730#M96051</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;Can someone tell me how to 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;Thanks all!&lt;/A&gt;</description>
      <pubDate>Tue, 15 May 2007 19:26:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000730#M96051</guid>
      <dc:creator>OMGPLSHELP</dc:creator>
      <dc:date>2007-05-15T19:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Menu-Driven Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000731#M96052</link>
      <description>Have a look at this page:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.esscc.uq.edu.au/~ksteube/Bshell/#page_25" target="_blank"&gt;http://www.esscc.uq.edu.au/~ksteube/Bshell/#page_25&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, 'man sh-posix' (the POSIX shell man page) has syntax examples.</description>
      <pubDate>Tue, 15 May 2007 20:10:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000731#M96052</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-05-15T20:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Menu-Driven Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000732#M96053</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;read choice&lt;BR /&gt;eval ${choice}&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 15 May 2007 20:18:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000732#M96053</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-15T20:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Menu-Driven Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000733#M96054</link>
      <description>&lt;P&gt;JRF has the command being entered by the user. Is this what you want? (The user could enter "rm -rf /". )-:&lt;BR /&gt;&lt;BR /&gt;In my reply to your same question in:&lt;BR /&gt;&lt;A target="_blank" href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=993074"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=993074&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://h30499.www3.hp.com/t5/Languages-and-Scripting/Sample-Shell-Script-with-Menu/m-p/3712343"&gt;http://h30499.www3.hp.com/t5/Languages-and-Scripting/Sample-Shell-Script-with-Menu/m-p/3712343&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I had:&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 "+ Enter 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;echo "Select the compare mode:"&lt;BR /&gt;select DT in "-r" "-b" "-a"; do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;BR /&gt;done&lt;BR /&gt;if [ "$DT" = "" ]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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, 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;"") date ;;&lt;BR /&gt;... # other choices&lt;BR /&gt;*) echo "invalid choice: ${choice}" ;;&lt;BR /&gt;esac﻿&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2011 04:19:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/writing-a-menu-driven-script/m-p/4000733#M96054</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-03T04:19:47Z</dc:date>
    </item>
  </channel>
</rss>

