- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Skip sequence in HP-UX shell programming
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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-06-2003 02:31 AM
07-06-2003 02:31 AM
Skip sequence in HP-UX shell programming
I wonder if I could set a step in a script where I can skip a step in the written program after a brief time. this is available in DOS, but I don't know if it is available in HP-UX. in other words, if the command line ask you whether you want to make a copy of something during a buckup process and you would like the system to have a default answer "no"..
is it possible..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2003 06:10 AM
07-06-2003 06:10 AM
Re: Skip sequence in HP-UX shell programming
#!/usr/bin/ksh
echo "do you wish to do next thing y/n (default no) ==>"
read ans
if [ $ans -eq y ]
then
echo "this is the next step"
fi
echo "this is the 2nd step"
Regards
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2003 07:23 AM
07-06-2003 07:23 AM
Re: Skip sequence in HP-UX shell programming
welcome to the forum.
your questions is not easily understood. just tell us what you want done. its that simple.
anyway in shell scripting you can use the powerfull case (switch) command to do just what you would like to achieve.
..
..
# echo to screen what you want the user to do
printf "What would you like to do next:\c\n"
# \c will a ding sound to attract the users attention
# \n is a new line, where your script will wait for the user to enter something
# now let the user know they 2 choices y/n with no being default
printf "To continue with this step (Y/[N])\n"
read ans
case in $ans
y|Y)
do your next step;;
*)
exit 1;;
esac
# the case statement will only understand y or Y. anything else. will exit.
enjoy
live free or die
donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2003 12:02 PM
07-06-2003 12:02 PM
Re: Skip sequence in HP-UX shell programming
If you want to use default this depend
on how you disign the script, you
can set the default to variable and use it.
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2003 06:15 PM
07-06-2003 06:15 PM
Re: Skip sequence in HP-UX shell programming
Before go to next step, system give a prompt "Do you want to continue? (Y/N)", this prompt will keep 10 seconds(for example) to wait a user to input 'Y' or 'N', if time exceed, system set the default input 'N' and go to next step.
I know the idea but I must take some time to write the script and test!
Just a monent...
:p
-ux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2003 10:43 PM
07-06-2003 10:43 PM
Re: Skip sequence in HP-UX shell programming
is what you require, the same as what hpux (user houx) has interpreted.
if so, spwan a new shell which asks for the input in background and wait on the pid. spawn another shell and sleep for ten seconds or so,
if the first script returns a value first, kill the sleep script and proceed. if the sleep script returns first, the user hasnt responded in the pre-determined step. kill it and proceed with default option.
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2003 10:49 PM
07-06-2003 10:49 PM
Re: Skip sequence in HP-UX shell programming
to help us in doing the translation to hpux, would you tell us how you do in DOS?
Many of us used the dos (i began with dos 3.0), so i think we can understand better with the example.
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 03:31 AM
07-07-2003 03:31 AM
Re: Skip sequence in HP-UX shell programming
choice=`line -t 30`
basically what the above line does is replaces a read statement in a script.
example:
echo "what is your name"
read name
echo $name #will respond with the entered answer
in the first case you could say
echo "enter name"
name=`line -t 30`
if [ "$name" = "" ]
then
echo "you did not enter your name"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 07:45 PM
07-07-2003 07:45 PM
Re: Skip sequence in HP-UX shell programming
thank you all again..
regards,
M. Z. Harbi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2003 10:03 PM
07-07-2003 10:03 PM
Re: Skip sequence in HP-UX shell programming
to understand better my previous question,
I want to write a program where there is this question:
do you want to continue? (y/n)
now, off course, there will be two cases, but if I want add a third case that lets the program wait for sometime (30 sec) and if there is no answer, it will set the default answer (no). and continue..
regards,
M. Z. Harbi