HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script question
Operating System - HP-UX
1833006
Members
3394
Online
110048
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 11:21 PM
05-23-2007 11:21 PM
How do I work with a command in a script that prompts for a Yes or No?
This is the command that waits for user input-
johnsonr@nmsccm01 > /opt/CSCOpx/campus/bin/reinitdb.pl
This will erase all data from the database. Are you sure [y/n] ?
I want to answer y in the script below. How can I accomplish this?
****************************************
#!/bin/sh
#set date variables
my_yr=`date +%y`
my_mon=`date +%b`
my_day=`date +%d`
my_hr=`date +%H`
my_min=`date +M`
my_date="$my_yr$my_mon$my_day"
#make backup of the ANIServer.properties file
cp /opt/CSCOpx/campus/etc/cwsi/ANIServer.properties /opt/CSCOpx/campus/etc/cwsi/ANIServer.properties.23May07
#copy new ANIServer.properties file
cp /tmp/ANIServer.new /opt/CSCOpx/campus/etc/cwsi/ANIServer.properties
#Reinitialize the ANI Database
/opt/CSCOpx/campus/bin/reinitdb.pl
***********************************************
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 11:30 PM
05-23-2007 11:30 PM
Solution
Shalom
snippet
echo "Do you want to proceed y/n "
read proceed
if [ "$proceed" == "y" ]
then
echo "delete data
# delete data
else
echo "doing nothing, have a nice day"
fi
SEP
snippet
echo "Do you want to proceed y/n "
read proceed
if [ "$proceed" == "y" ]
then
echo "delete data
# delete data
else
echo "doing nothing, have a nice day"
fi
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 11:54 PM
05-23-2007 11:54 PM
Re: Script question
Hi Rob,
two ways:
first:
# echo y | /opt/CSCOpx/campus/bin/reinitdb.pl
second:
# /opt/CSCOpx/campus/bin/reinitdb.pl < y
EOC
Both give "y" to the program so it can continue.
rgds
HGH
two ways:
first:
# echo y | /opt/CSCOpx/campus/bin/reinitdb.pl
second:
# /opt/CSCOpx/campus/bin/reinitdb.pl <
EOC
Both give "y" to the program so it can continue.
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 06:01 PM
05-24-2007 06:01 PM
Re: Script question
In regards to both SEP's and HGH's solutions, you may want to check to see if the script is interactive, and then not ask.
You can use tty(1):
$ if tty -s; then echo it is a tty; fi
You can use tty(1):
$ if tty -s; then echo it is a tty; fi
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP