- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Bourne Shell Programming Input and Output
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
Discussions
Forums
Discussions
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
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
10-14-2002 03:53 AM
10-14-2002 03:53 AM
Re: Bourne Shell Programming Input and Output
I give you a more documented script with some new features ... The usage will be :
getinput -u
Usage : getinput [-u] [-m max] [-n] [-e] [-f]
accept a string
-e : don't accept empty strings
-f : strings must have exact length
-m : max number of characters (default '4')
-n : filters non numeric characters
-u : usage
1) What if i want to enter alphanumeric how do i validate in your script?
You just have to delete 2 lines (or change the filter).
VAR=$(echo $VAR | tr -cd '[0-9.]')
[ -z "$VAR" ] && beep
In fact these lines suppress all chars except in the range 0 to 9 or '.'. So you could use for example [a-zA-Z0-9._] or suppress the lines to have no filter.
2) If there is more than 2 inputs:
Enter number : [0000] (4 numbers)
Enter name : [aaaaaaaaaaa] (11 alphabets)
Do i need to do validations for both the inputs or ?
You could easily modify the script to use parameters for MAX (max length) and FILTER (the filter string for 'tr')
3) If there is more than 10 inputs using this method, will it increase the unix uptime?
I don't think so ...
4) Which line of code disable the usage of crtl + c, ctrl + d, etc?
The stty command does it ('raw' flag)
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:26 AM
10-14-2002 04:26 AM
Re: Bourne Shell Programming Input and Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:47 AM
10-14-2002 04:47 AM
Re: Bourne Shell Programming Input and Output
Perhaps you could try keysh or tsm.
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 08:00 AM
10-14-2002 08:00 AM
Re: Bourne Shell Programming Input and Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 08:11 AM
10-14-2002 08:11 AM
Re: Bourne Shell Programming Input and Output
You have to use a TERM for which you have a file '.fi' in /usr/tsm/term (for example alamost all vtxxx, hpterm, ...). Then use CTRL-T for menu.
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 08:28 AM
10-14-2002 08:28 AM
Re: Bourne Shell Programming Input and Output
sh: /usr/tsm/term: Permission denied
but when i cd /usr, and cd tsm:
sh: tsm: not found.
Any idea? Is tsm is preconfigured in all HP-UX? The HP-UX 10.20 that we are using is not configured with xwindows? Is it related?
No other ways than using tsm? Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 11:43 PM
10-14-2002 11:43 PM
Re: Bourne Shell Programming Input and Output
In fact /usr/tsm/term is only the directory where terminal descriptions are stored. tsm is installed on your system since you got the error 'cannot open ansi.fi'. So you should also have other terminal descriptions. Try a 'find / -name '*.fi' to locate these files (but they should be in /usr/tsm). If you need to reinstall them, they are in the product 'TerminalMngr' on the HP-UX CD.
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 02:45 AM
10-15-2002 02:45 AM
Re: Bourne Shell Programming Input and Output
2) Dear Jean-Louis, i had tested your code but i had some confusion here where i try to apply your getinput concepts on multiple inputs. Example:
Enter name : [aaaaaaaaaa] (10 alphabets)
Enter student id : [aa0000] (6 alphanumeric)
Enter age : [00] (2 numbers)
I do not how to combine multiple inputs with one validation. Any sample script to show me. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 06:16 AM
10-15-2002 06:16 AM
Re: Bourne Shell Programming Input and Output
Here is an example of script which would use a modified version of previous getinput script as a "library" of function. I attached the modified getinput ...
----------------------------
#!/usr/bin/sh
. getinput
# get a mandatory (-e) string name (-s name)(alphbetical -a)
# max length 10 (-m 10) in variable NAME (-v NAME)
getinput_main -e -m 10 -a -s "name" -v NAME
# get a mandatory (-e) string student id (-s "student id" ) alphanumerical
# max length 6 (-m 6) fixed length (-f) in variable ID (-v ID)
getinput_main -e -m 6 -f -s "student id" -v ID
# get a mandatory (-e) string age (-s age)(numeical -n)
# max length 2 (-m 2) in variable AGE (-v AGE)
getinput_main -e -m 2 -n -s "age" -v AGE
echo "\n$NAME (id $ID) is $AGE years old\n"
----------------------------
Best regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 12:58 AM
10-18-2002 12:58 AM
Re: Bourne Shell Programming Input and Output
I try the modified getinput, but when i run getinput -u, i did not see any output. Is there any problem with the modifed code? i had tried the old version but it is working.
Based on your previous reply:
#!/usr/bin/sh
. getinput
# get a mandatory (-e) string name (-s name)(alphbetical -a)
# max length 10 (-m 10) in variable NAME (-v NAME)
getinput_main -e -m 10 -a -s "name" -v NAME
# get a mandatory (-e) string student id (-s "student id" ) alphanumerical
# max length 6 (-m 6) fixed length (-f) in variable ID (-v ID)
getinput_main -e -m 6 -f -s "student id" -v ID
# get a mandatory (-e) string age (-s age)(numeical -n)
# max length 2 (-m 2) in variable AGE (-v AGE)
getinput_main -e -m 2 -n -s "age" -v AGE
echo "\n$NAME (id $ID) is $AGE years old\n"
Is that the command that i need to type in order to run this script. I had tried to change the scipt name to getinput_main but it ends up nothing.
Thanks for your help but what actually i want is able to enter more than 1 inputs at a time with your script? I think (i did not able to compile you script) your modified version is more on displaying the output with few variables.
Anyway thanks a lot. :D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 02:08 AM
10-18-2002 02:08 AM
Re: Bourne Shell Programming Input and Output
perhaps my answer were not evry clear ... I gave you in my previous message a new release of the getinput script which can't be used anymore as a script, but now rather as a library of functions.
So you should write your own script (I gave you only an example) which would call my getinput. The line '. getinput' "includes" the functions defined in getinput into your script.
So the most simple example without comment could be a script named 'toto' :
#!/usr/bin/sh
. getinput
getinput_main -e -m 10 -a -s "name" -v NAME
getinput_main -e -m 6 -f -s "student id" -v ID
getinput_main -e -m 2 -n -s "age" -v AGE
echo "\n$NAME (id $ID) is $AGE years old\n"
the getinput_main function is now in the new getinput script. So if your PATH contains '.' just try to save my new getinput and this five lines script in the same directory, make them executable and run 'toto'.
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 06:37 AM
10-18-2002 06:37 AM
Re: Bourne Shell Programming Input and Output
-----------------------
I finally understand what you meant by the previous messages. About '.' (dot), is it something like import in java?
I just find out that i had a big major problem. As you can see, if i ask the end user to enter his/her name (names include spaces, example 'Chua Wen Ching' - 2 spaces), the script that you show me will not allow spaces ('ChuaWenChing').
How do you solve this situation? Thank you. :D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2002 06:34 AM
10-19-2002 06:34 AM
Re: Bourne Shell Programming Input and Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2002 07:15 AM
10-19-2002 07:15 AM
Re: Bourne Shell Programming Input and Output
The manuak is no longer published, but maybe you can find it elsewhere:
Terminal Session Manager User's Guide
B2351-90000
Some other info:
http://docs.hp.com/hpux/onlinedocs/B2355-90046/B2355-90046.html
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2002 05:53 PM
10-19-2002 05:53 PM
Re: Bourne Shell Programming Input and Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2002 08:04 AM
10-20-2002 08:04 AM
Re: Bourne Shell Programming Input and Output
it looks like any other screen. The only difference is that you can use "ctrl-a" features to move between one session and another. There really isn't any terminal screen shots that are of any value.
Let's say you have define 4 sessions, and you are in session #2 and you start some very large compile job that's going to take hours, so once you start it, you can use the "ctrl-a4" feature to move to session 4. To move to session #1 you can either use ctrl-an (thats a control "a" then an "n" (not a control n)).
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2002 11:56 PM
10-20-2002 11:56 PM
Re: Bourne Shell Programming Input and Output
I had some problems with my 'tr ' command, so I changed the line and finally used the standard class filters. Blanks should now be accepted in alpha and alphanum. Try with this new 'getinput' but don't hesitate to modify my filters ...
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 12:50 AM
10-21-2002 12:50 AM
Re: Bourne Shell Programming Input and Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 12:52 AM
10-21-2002 12:52 AM
Re: Bourne Shell Programming Input and Output
Nothing else than filters lines and tr line have changed, so you can still use toto ...
Regards,
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 07:39 AM
10-21-2002 07:39 AM
Re: Bourne Shell Programming Input and Output
- « Previous
-
- 1
- 2
- Next »