<?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: How to by pass a prompt in a script. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969515#M95284</link>
    <description>Perhaps the easiest method is to pass a value on the command line; e.g. let $1 = ENV&lt;BR /&gt;Essentially we set ENV = "" and then assign it to ${1}. If the length of ${ENV} is zero then you need to prompt the user otherwise enter the case statement.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset ENV=""&lt;BR /&gt;if [[ ${#} -gt 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    ENV=${1}&lt;BR /&gt;    shift&lt;BR /&gt;  fi&lt;BR /&gt;if [[ -z "${ENV}" ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Enter an environment TST,DEV,PRD,DMO, or PERF: \c" &lt;BR /&gt;    read ENV&lt;BR /&gt;  fi&lt;BR /&gt;case ${ENV} in&lt;BR /&gt;.... the rest is the same as your existing script</description>
    <pubDate>Mon, 26 Mar 2007 17:11:57 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-03-26T17:11:57Z</dc:date>
    <item>
      <title>How to by pass a prompt in a script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969514#M95283</link>
      <description>I am putting part of the .profile where is gets prompted to enter the instance you want to work with, and is as follow:&lt;BR /&gt;&lt;BR /&gt;echo "Enter an environment TST,DEV,PRD,DMO, or PERF:"        &lt;BR /&gt;read ENV                                                     &lt;BR /&gt;#                                                            &lt;BR /&gt;case $ENV in                                                 &lt;BR /&gt;        TST|1)                                               &lt;BR /&gt;        echo "You entered (TST) :\n";                        &lt;BR /&gt;        export MYBAN=TEST                                    &lt;BR /&gt;        export PSADM=/u04/psoft/CRM89TST/pt845/crm89/appserv &lt;BR /&gt;        export PS_HOME=/u04/psoft/CRM89TST/pt845/crm89       &lt;BR /&gt;        . /u04/psoft/CRM89TST/pt845/crm89/psconfig.sh        &lt;BR /&gt;        ;;                                                   &lt;BR /&gt;        DEV|2)                                               &lt;BR /&gt;        echo "You entered (DEV) :\n";                        &lt;BR /&gt;        export MYBAN=DEVELOP                                 &lt;BR /&gt;        export PSADM=/u04/psoft/CRM89DEV/pt845/crm89/appserv &lt;BR /&gt;        export PS_HOME=/u04/psoft/CRM89DEV/pt845/crm89       &lt;BR /&gt;        . /u04/psoft/CRM89DEV/pt845/crm89/psconfig.sh        &lt;BR /&gt;        ;;                                                   &lt;BR /&gt;Since we want to shutdown PeopleSoft using a cron job, we do not want it to be prompted and continue with the shutdown as normal. Since we have 5 or 6 different environment the user needs to put what environment will be working with and it gets re-directed to his choice. If you could help on what do I need to put in order to by pass the prompt, I would really appreciated.&lt;BR /&gt;&lt;BR /&gt;Thank you so much!&lt;BR /&gt;&lt;BR /&gt;** removed email address to comply with forum guidelines **</description>
      <pubDate>Mon, 26 Mar 2007 16:59:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969514#M95283</guid>
      <dc:creator>Reynaldo Torres</dc:creator>
      <dc:date>2007-03-26T16:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to by pass a prompt in a script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969515#M95284</link>
      <description>Perhaps the easiest method is to pass a value on the command line; e.g. let $1 = ENV&lt;BR /&gt;Essentially we set ENV = "" and then assign it to ${1}. If the length of ${ENV} is zero then you need to prompt the user otherwise enter the case statement.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset ENV=""&lt;BR /&gt;if [[ ${#} -gt 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    ENV=${1}&lt;BR /&gt;    shift&lt;BR /&gt;  fi&lt;BR /&gt;if [[ -z "${ENV}" ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Enter an environment TST,DEV,PRD,DMO, or PERF: \c" &lt;BR /&gt;    read ENV&lt;BR /&gt;  fi&lt;BR /&gt;case ${ENV} in&lt;BR /&gt;.... the rest is the same as your existing script</description>
      <pubDate>Mon, 26 Mar 2007 17:11:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969515#M95284</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-26T17:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to by pass a prompt in a script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969516#M95285</link>
      <description>&lt;!--!*#--&gt;It would be best to test whether a tty is available before trying to ask things from user in .profile:&lt;BR /&gt;&lt;BR /&gt;if tty -s&lt;BR /&gt;then&lt;BR /&gt;    # we have a TTY and can ask things&lt;BR /&gt;    echo "Enter an environment:"&lt;BR /&gt;    read ENV&lt;BR /&gt;    #...&lt;BR /&gt;else&lt;BR /&gt;    # we do not have a TTY.&lt;BR /&gt;    # Don't ask anything, because the prompt&lt;BR /&gt;    # might break things like rcp/scp/rdist/&lt;BR /&gt;    # rsync or cron jobs.&lt;BR /&gt;    # Set the environment variables to some&lt;BR /&gt;    # sensible default values.&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Mar 2007 00:35:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969516#M95285</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2007-03-27T00:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to bypass a prompt in a script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969517#M95286</link>
      <description>&lt;P&gt;You can also use the following to check to see if you are an interactive shell:&lt;BR /&gt;if [ "${-%%*i*}" != "$-" ]; then&lt;BR /&gt;&lt;BR /&gt;But perhaps Matti's solution would be better in scripts, where mine better for .profile.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, you should NOT be using ENV for a variable because ENV has a special meaning for a real shell!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2011 03:57:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969517#M95286</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-10T03:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to by pass a prompt in a script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969518#M95287</link>
      <description>Hi,&lt;BR /&gt;just another possbile test:&lt;BR /&gt;if [[  $(tty) != "not a tty" ]]; then&lt;BR /&gt;  # BEGIN interactive section&lt;BR /&gt;  # END intercative sectin&lt;BR /&gt;  &lt;BR /&gt;  put here all yoy command which requires    &lt;BR /&gt;  terminal (i.e.: terminal setup) or  &lt;BR /&gt;  interaction with user&lt;BR /&gt;else&lt;BR /&gt;  # BEGIN batch section&lt;BR /&gt;  # END batch sectin&lt;BR /&gt;fi&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 28 Mar 2007 03:08:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-by-pass-a-prompt-in-a-script/m-p/3969518#M95287</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-03-28T03:08:07Z</dc:date>
    </item>
  </channel>
</rss>

