- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script problem with read command...
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
05-07-2003 12:38 PM
05-07-2003 12:38 PM
Basically I want to read through a file and ask if they want to process this record or not ....
while read turntype project filename revision
do
print "Processing line: "
print "Processing line: " >> ${PVCS_LOG5}
print "${turntype} ${project} ${filename} ${revision} "
print "${turntype} ${project} ${filename} ${revision} " >> ${PVCS_LOG5}
ask "Process this Regression Record? (Y/N) "
if [ $? -eq 0 ]
then
if [ ${TYPE} = "tupinstallprod" ]
then
......etc....
function ask
{
typeset rc
rc=2
while [ ${rc} -gt 1 ]
do
print -n ${1}
sleep 2
read answer
if [ "${answer}" = "Y" -o "${answer}" = "y" ]; then
rc=0
elif [ "${answer}" = "N" -o "${answer}" = "n" ]; then
rc=1
else
rc=2
fi
done
return ${rc}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2003 12:53 PM
05-07-2003 12:53 PM
Solutionread answer <&2
This will force read to read from your STDERR (assuming to be the terminal).
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2003 12:54 PM
05-07-2003 12:54 PM
Re: script problem with read command...
In order to keep the reads "straight" you need to establish another file descriptor. By example:
#!/usr/bin/sh
exec 3<&0
while read LINE
do
echo "${LINE}
read -u3 REPLY
echo "You said: ${REPLY}"
done < filename
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2003 01:11 PM
05-07-2003 01:11 PM
Re: script problem with read command...
As an aside, here's one other trick you will find useful. Instead of testing your 'answer' variable for uppercase and lowercase letters, use 'typeset -l' to translate to lowercase when variable assignment is made:
typeset -l answer
read -u3 answer
if [ "${ansser}" = y ]; then
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2003 01:18 PM
05-07-2003 01:18 PM
Re: script problem with read command...
e.g. read answer < /dev/tty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2003 05:10 AM
05-08-2003 05:10 AM
Re: script problem with read command...
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xfdac3a7b3682d611abdb0090277a778c,00.html
Thanks,
Kurt Renner