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
тАО08-22-2006 03:36 AM
тАО08-22-2006 03:36 AM
I have a script which I get the line counts from three servers. For an instance, I get the output from the script 30, 34 and 37. I wanted to add these three numbers dynamically in the script itself so that I don't need to add manually. I know I can use "bc" command from unix prompt but I want add the number what I get from the output in the script itself. Any help is greatly appreciated?
Thanks,
Pratibha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 03:41 AM
тАО08-22-2006 03:41 AM
Re: Addition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 03:41 AM
тАО08-22-2006 03:41 AM
Solutiontypeset -i A=30
typeset -i B=34
typeset -i C=37
typeset -i TOT=0
TOT=$(( ${A} + ${B} + ${C} ))
echo "Total: ${TOT}"
You can also call the external command expr to add these values but the POSIX and Korn shell will handle this all internally.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 03:45 AM
тАО08-22-2006 03:45 AM
Re: Addition
#!/bin/ksh
NODES="xx yy zz"
for i in $NODES
do
{
echo " "
echo "*************************${i}****************************"
echo " "
rsh ${i} "ps -ef|grep ora | wc -l"
}
done
# THE END!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 04:00 AM
тАО08-22-2006 04:00 AM
Re: Addition
#!/usr/bin/ksh
typeset NODES="xx yy zz"
typeset -i=""
typeset -i TOT=0
typeset -i K=0
for i in ${NODES}
do
{
echo " "
echo "*************************${i}****************************"
echo " "
K=$(remsh ${i} ps -ef | grep ora | wc -l)
((TOT+=K))
}
done
echo "Total: ${TOT}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 04:14 AM
тАО08-22-2006 04:14 AM
Re: Addition
Thank you for the response but erroring out at typeset, saying typeset: bad options. Any ideas?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 04:19 AM
тАО08-22-2006 04:19 AM
Re: Addition
typeset -i K=0
to simply K=0
The typeset is optional but it does make the computations more efficient.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 04:21 AM
тАО08-22-2006 04:21 AM
Re: Addition
typeset -i=""
It should be
typeset i=""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 04:27 AM
тАО08-22-2006 04:27 AM
Re: Addition
Thanks again,
Pratibha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2006 08:08 PM
тАО08-22-2006 08:08 PM
Re: Addition
looking at your script I found an error: using ps -ef|grep ora|wc -l we include in the count also the command line. To avoid this use: ps -ef|grep [o]ra|wc -l. In this way we will the correct counter.
But if your goal is know the numnber of Oracle process this is wrong because using ora you got also all teh process for user oracle.
Just my .02$
HTH,
Art