- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help With parameter in Script
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
06-08-2001 07:41 AM
06-08-2001 07:41 AM
I need some help from script export for parameter use. I have a script to get date and count of email number to send out to put into message. The codes:
------------
bbb=`date`
ccc=`date '+%b %e'`
ddd=`grep ipaddress syslog.log | grep -c "$ccc 02:"`
echo "Hello, " >>mesg
echo "We have sent $ddd email messages on $bbb." >> mesg
---------------------------
grep -c "$ccc 02:" is not working. Put in the first part of line is the same.
I try "sed -n /$ccc 02:/p' filename", not working. (Supposed I have a file created by
"grep ipaddress syslog > filename" first.
I don't know why the parameter can not work this way.
Please help.
Thanks a lot,
Steven
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 08:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 08:31 AM
06-08-2001 08:31 AM
Re: Help With parameter in Script
I'm with Clay. I don't see anything obviously wrong. One thought, however: are you sure that you have IPaddresses and not DNS names in syslog?
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 08:51 AM
06-08-2001 08:51 AM
Re: Help With parameter in Script
First just try
grep ipaddress syslog.log , it chould give you some output , incase there is no outpput then you can pipe that out . I dont thionk anythin else looks wrong.
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 09:49 AM
06-08-2001 09:49 AM
Re: Help With parameter in Script
E.g. on the code:
-----------------------
ccc=`date '+%b %e'`
ddd=`grep ipaddress syslog.log | grep -c "$ccc 02:"`
-----------------------
I should have 700 counts today, but I get 800 counts instead including 100 counts from yesterday. So the 2nd grep filter is not working, though it lets condition through. Put it in the first grep place resulting the same.
That's what I would like to see the parameter $ccc working.
Can you help please?
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 10:04 AM
06-08-2001 10:04 AM
Re: Help With parameter in Script
Would you post your syslog and the *values* of the interpreted variables you are using?
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 10:08 AM
06-08-2001 10:08 AM
Re: Help With parameter in Script
ccc=`/bin/date '+%b %e'`
ddd=`grep ipaddress syslog.log | grep -c "${ccc} 02:"`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 10:10 AM
06-08-2001 10:10 AM
Re: Help With parameter in Script
Again nothing obvious; posting your logfile
(or at least a portion of it exhibiting the problem) will really help.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 10:41 AM
06-08-2001 10:41 AM
Re: Help With parameter in Script
I would post some log files for reference:
---------------------------------------------
Jun 8 02:17:24 6C:IRIS sendmail[13277]: CAA13277: from=
l.appp.com>, proto=ESMTP, relay=exchs [111.222.333.444]
Jun 8 02:17:24 6C:IRIS sendmail[13283]: CAA13283: from=
l.appp.com>, proto=ESMTP, relay=exchs [111.222.333.444]
------------------------------------------
There is some problem on website for me to offer points for each who are so helpful. Will do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 11:21 AM
06-08-2001 11:21 AM
Re: Help With parameter in Script
I'm grasping at straws here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 11:36 AM
06-08-2001 11:36 AM
Re: Help With parameter in Script
I notice the space issue. If I use "grep -c "Jun 8" syslog", I have no problem. Is it a matter of parameterfailing to work?
If I use "ddd=grep date|grep -c ipaddress syslog", I get all 800 counts. It tells me that the date part is problematic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 12:00 PM
06-08-2001 12:00 PM
Re: Help With parameter in Script
I don't think the
# X=`date`
# echo $X
# echo "$X"
This is normal, expected shell behavior.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 12:01 PM
06-08-2001 12:01 PM
Re: Help With parameter in Script
I think this will fix you, we need to eat the spaces:
mo=`date '+%b' | tr -d " "`
da=`date '+%e' | tr -d " "`
ccc="${mo} ${da}"
Put that in your script. I am curious why you only care about 02 hours.
Have fun, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 12:20 PM
06-08-2001 12:20 PM
Re: Help With parameter in Script
-------------------
IRIS 50# date '+%b %e'
Jun 8
IRIS 51# date
Fri Jun 8 16:12:43 EDT 2001
----------------------
Both "Jun 8" have proper space in this system.
Any more help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 01:22 PM
06-08-2001 01:22 PM
Re: Help With parameter in Script
grep ipaddress|grep -c "Jun 8" syslog
and I get the correct count.
While I do not have confidence in this unix shell I am working with, can someone think of other editor that might work?
I know this works:
sed -n '/Jun 8 02:/p' syslog|wc -l
but I feel parameter for "Jun 8" is hard to accept.
Someone knows more about sed please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2001 01:54 PM
06-08-2001 01:54 PM
Re: Help With parameter in Script
Your problem is that you are going to have to build the sed string 'on the fly'. I'm very puzzled by this, since %e always prints 2 characters.
Anyway if you want to use sed, do this:
mo=`date '+%b' | tr -d " "`
da=`date '+%e' | tr -d " "`
ccc="/${mo}[ ]*${da}[ ]*02:/p"
knt = `cat syslog | sed -n -e "${ccc}" | wc -l`
echo "${knt} entries found"
The idea is we build the sed string. The '[ ]*'
matches any number of spaces.
Try that, Clay