- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script issue.
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
01-19-2004 07:30 AM
01-19-2004 07:30 AM
for varname in $(cat /opt/omni/lbin/hosts.lst)
do
grep -i $varname /tmp/fail.out > log.out
done
Thank
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 07:36 AM
01-19-2004 07:36 AM
Re: Shell Script issue.
Try ">>" instead of ">" in the third line.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 07:36 AM
01-19-2004 07:36 AM
Re: Shell Script issue.
cat /opt/omni/lbin/hosts.lst | while read varname
do
grep -i $varname /tmp/fail.out >> log.out
done
Regards
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 07:37 AM
01-19-2004 07:37 AM
Re: Shell Script issue.
rm -f log.out
for varname in $(cat /opt/omni/lbin/hosts.lst)
do
grep -i "${varname}" /tmp/fail.out >> log.out
done
That should fix you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 07:38 AM
01-19-2004 07:38 AM
Solution#!/usr/bin/sh
set -x
for varname in $(cat /opt/omni/lbin/hosts.lst)
do
grep -i $varname /tmp/fail.out > log.out
done
Or you can run the script using this syntax:
sh -x your_script
If the list of hosts is very long, use more to slow it down and 2>&1 to re-route the trace information to stdout:
sh -x your_script 2>&2 | more
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 07:41 AM
01-19-2004 07:41 AM
Re: Shell Script issue.
I would consider something like this:
#!/usr/bin/sh
rm log.out
for varname in $(cat /opt/omni/lbin/hosts.lst)
do
HOST=$(grep -i ${varname} /tmp/fail.out)
if [[ ${HOST} != "" ]] ; then
echo $HOST >> log.out
fi
done
The above will do the grep and assign the result to HOST. Then if $HOST is NOT EMPTY it will write the value to log.out. Note the >> in the echo. That will append to the log.out file so that you get all possible results. If you still want to use your own script you can replace your > with >> but your log.out file may have some blank lines it when the grep doesn't return anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2004 05:48 PM
01-19-2004 05:48 PM
Re: Shell Script issue.
....
done > log.out
(or done >> log.out).
This is especially interesting if there is more than 1 command in the for-loop.
JP