- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: read values from a text file.
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
Discussions
Discussions
Forums
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
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
тАО11-23-2009 09:25 PM
тАО11-23-2009 09:25 PM
read values from a text file.
I need to customize the script
##################
clear
echo "Enter IP or x to quit > \c"
while read ip
do
[ "${ip}" = "x" ] && exit 0
/opt/OV/bin/snmpwalk -c test ${ip}|more
echo "Enter IP or x to quit > \c"
done
##########################
In this script i need to press x and enter the ip address.Instead of that i need to read the ipaddress from a text file and execute the command.
Thanks in advance.
Th
- Tags:
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2009 09:28 PM
тАО11-23-2009 09:28 PM
Re: read values from a text file.
while read ip
do
[ "${ip}" = "x" ] && exit 0
/opt/OV/bin/snmpwalk -c test ${ip}|more
echo "Enter IP or x to quit > \c"
done < ip_addr_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2009 10:02 PM
тАО11-23-2009 10:02 PM
Re: read values from a text file.
Since you are reading from a file, there is probably no need for the check for "x" and the echo:
while read ip; do
/opt/OV/bin/snmpwalk -c test ${ip} | more
done < ip_addr_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2009 10:52 PM
тАО11-23-2009 10:52 PM
Re: read values from a text file.
Thanks for the response,
Its working fine.Please take this example.I want to redirect the err to one file and normal; o/p to another.
################################
clear
while read ip; do
/usr/sbin/ping ${ip} -n 3 $2>pingerr|tee $1>output
done < /tmp/ipfile
####################################
please correct this if i went wrong some where.b'coz am not getting the file updated .i.e pingerr and output.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2009 11:18 PM
тАО11-23-2009 11:18 PM
Re: read values from a text file.
Do you mean "2>" and "1>"?
man
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2009 12:23 AM
тАО11-24-2009 12:23 AM
Re: read values from a text file.
You probably need to append:
while read ip; do
/usr/sbin/ping ${ip} -n 3 2>> pingerr | tee -a output
done < /tmp/ipfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-25-2009 01:07 AM
тАО11-25-2009 01:07 AM
Re: read values from a text file.
preparare a file with the listf of IPs and x at the end:
255.255.1.2
255.255.1.3
x
run your script (without changing it!!!) using the file created:
your_script
No changes to your script, no need to retest it. (you can countinue to use it in interactive mode as before)
first priciple of the programmers:
never touch working script!
HTH,
Art