HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: need help with scriping
Operating System - HP-UX
1833197
Members
3098
Online
110051
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
07-17-2003 01:51 PM
07-17-2003 01:51 PM
I have to put a startup script in the init.d to start an application, please help...for instance :
cd /usr/home/life
./life1 <--- give you a menu where you have to select a number.
1.yes
2.no
** how can i write it in such, it will automatically pick 1 instead of waiting for the user?
Please help
cd /usr/home/life
./life1 <--- give you a menu where you have to select a number.
1.yes
2.no
** how can i write it in such, it will automatically pick 1 instead of waiting for the user?
Please help
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 01:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 02:08 PM
07-17-2003 02:08 PM
Re: need help with scriping
It sounds as if you need to use the "line" command as this allows you to specify a timeout period, specified in seconds.
If the following example script is run interactively, the user is given a window in which to make a decision, else it will apply a default. If you take this approach, make sure the default value will not perform any unwanted actions.
#!/usr/bin/env ksh
echo "Please enter Y to continue (default=N) \c"
REPLY="$(line -t 30)"
case ${REPLY:="N"} in
Y|y) echo "Y was selected !!"
;;
N|n) echo "N was selected !!"
;;
*) echo "Invalid option !!"
;;
esac
Another alternative would be to check to see if the script is being run in an interactive session - if not, apply a default. For example:
#!/usr/bin/env ksh
if [ "$(ttytype)" = "" ]
then
# Non interactive session - ie cron or rc !
echo "Default of N has been applied !!"
else
echo "Enter 1 or 2 \c"
read REPLY
case ......
etc etc etc etc
Give that ago - they may allow you to do what you want within your scripts !!
Rgds,
Paul
If the following example script is run interactively, the user is given a window in which to make a decision, else it will apply a default. If you take this approach, make sure the default value will not perform any unwanted actions.
#!/usr/bin/env ksh
echo "Please enter Y to continue (default=N) \c"
REPLY="$(line -t 30)"
case ${REPLY:="N"} in
Y|y) echo "Y was selected !!"
;;
N|n) echo "N was selected !!"
;;
*) echo "Invalid option !!"
;;
esac
Another alternative would be to check to see if the script is being run in an interactive session - if not, apply a default. For example:
#!/usr/bin/env ksh
if [ "$(ttytype)" = "" ]
then
# Non interactive session - ie cron or rc !
echo "Default of N has been applied !!"
else
echo "Enter 1 or 2 \c"
read REPLY
case ......
etc etc etc etc
Give that ago - they may allow you to do what you want within your scripts !!
Rgds,
Paul
Hey, nobody knows EVERYthing !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 02:25 PM
07-17-2003 02:25 PM
Re: need help with scriping
Whatever value the script is waiting for the user to enter is probably read into a variable...just comment out the part where it asks the user the question, and hard code the varible to 1.
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