- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script - read doesn't work
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
03-12-2002 08:11 AM
03-12-2002 08:11 AM
For some reason, this script doesn't stop at read to read user answer (Y/N) and for somehow N is always assumed!
sed "s/,/ /g" $1|while read line
do
LVSTRING="${LVCREATE} -i ${LVSTRIP}"
echo "\n Striping will be used"
echo " Number of spindles to be used is "
echo "\nWould you like to change the number of spindles (y/n)[n]: \c"
read ans
ans=$(echo $ans |tr "[a-z]" "[A-Z]")
if [ "$ans" = "Y" ]; then
echo "YES"
else
echo "NO"
fi
fi
done
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:12 AM
03-12-2002 08:12 AM
Re: shell script - read doesn't work
#!/usr/bin/ksh
at the top of the script..
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:14 AM
03-12-2002 08:14 AM
Re: shell script - read doesn't work
Striping will be used
Number of spindles to be used is
Would you like to change the number of spindles (y/n)[n]: n
NO
Works for me:
kibo:root> cat /tmp/scr
echo "\n Striping will be used"
echo " Number of spindles to be used is "
echo "\nWould you like to change the number of spindles (y/n)[n]: \c"
read ans
ans=$(echo $ans |tr "[a-z]" "[A-Z]")
if [ "$ans" = "Y" ]; then
echo "YES"
else
echo "NO"
fi
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:15 AM
03-12-2002 08:15 AM
Re: shell script - read doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:17 AM
03-12-2002 08:17 AM
Re: shell script - read doesn't work
If I remove while loop it works, but I need to have while loops since its in the while loop I read file and determine striping
I hope read can work in the while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:18 AM
03-12-2002 08:18 AM
Re: shell script - read doesn't work
and multiple use of the same variable.
other than that, term emulation or env should be looked at.
Dis you try to add a set -x in the script.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:19 AM
03-12-2002 08:19 AM
Solutionthe line:
read ans
become:
read ans <&1
Hope this helps.
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:20 AM
03-12-2002 08:20 AM
Re: shell script - read doesn't work
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:22 AM
03-12-2002 08:22 AM
Re: shell script - read doesn't work
read -u3 ans
Then it will do it's input from STDERR and do a real input from the terminal, assuming you haven't redirected STDERR.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:22 AM
03-12-2002 08:22 AM
Re: shell script - read doesn't work
Would you like to change the number of spindles (y/n)[n]: n
NO
hello1111
Striping will be used
Number of spindles to be used is
Would you like to change the number of spindles (y/n)[n]: y
YES
hello111
Striping will be used
Number of spindles to be used is
Would you like to change the number of spindles (y/n)[n]: y
YES
hello11
where the script is:
for i in $(cat /tmp/file1)
do
echo "\n Striping will be used"
echo " Number of spindles to be used is "
echo "\nWould you like to change the number of spindles (y/n)[n]: \c"
read ans
ans=$(echo $ans |tr "[a-z]" "[A-Z]")
if [ "$ans" = "Y" ]; then
echo "YES"
else
echo "NO"
fi
echo $i
done
and the file1 is:
hello111111
hello11111
hello1111
hello111
hello11
~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:24 AM
03-12-2002 08:24 AM
Re: shell script - read doesn't work
read -u2 ans
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2002 08:24 AM
03-12-2002 08:24 AM
Re: shell script - read doesn't work
function prompt_user
{
print "Are you really really sure?"
read ans
export ans2=$ans
}
sed .... |while read line
do
prompt_user
/* Actions here */
done
Share and Enjoy! Ian