Sponsored Content
Operating Systems HP-UX Unable to pass a space inside a variable shell scripting Post 302843587 by Kits on Wednesday 14th of August 2013 03:15:04 AM
Old 08-14-2013
Thanks Krishmaths,

However, I need flexible output not confined to one date. Like if the dates are 1 - 9 I can grep the first two values from date including the two spaces and after 9 i.e. from 10 - 31 I don't need this variable.

Actually I have made a script which will throw a mail if any error or failure messages are encountered in /var/adm/syslog/syslog.log file. The script will automatically check the date and grep the errors|failures from today's date and mail us.

The sample script is below:

Code:
p=`date`
e=`echo $p | awk '{print $2,$3}'`
#tail -1 /var/adm/syslog/syslog.log | cut -c 1-6 > /tmp/val.txt
grep -i "$e" /var/adm/syslog/syslog.log > /tmp/temp.txt | egrep -i "error|failure" /tmp/temp.txt > /tmp/err.txt

cat /tmp/utilz.txt /tmp/err.txt > /tmp/status.txt
mailx -s "$sub" $email < /tmp/status.txt

The script is working fine for dates greater than 9 but not for 1 to 9.

Thanks,
Ankit

Last edited by Scott; 08-14-2013 at 04:15 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to Pass variable to shell Script

Hi , i am beginner to Unix, I have one small script which execute java programme,it has java command input output structure . Right now i have given Input output structure manually that is on same directory, now how can i pass that by commandline #!/bin/sh java Classjava input.txt... (5 Replies)
Discussion started by: sam70
5 Replies

2. Shell Programming and Scripting

how to pass a variable to an update sql statement inside a loop

hi all, i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code. sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE whenever sqlerror exit set serveroutput on size 1000000 declare l_rc ... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

3. Shell Programming and Scripting

nested double quota and white space inside variable

I have a question about nested double quotes. Any help is appreciated. Here are my commands on Mac OS. # string="Ethernet \"USB Ethernet\" \"Bluetooth DUN\" AirPort FireWire \"Bluetooth PAN\"" # echo $string Ethernet "USB Ethernet" "Bluetooth DUN" AirPort FireWire "Bluetooth PAN" #... (3 Replies)
Discussion started by: lindazhou
3 Replies

4. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

5. Shell Programming and Scripting

Pass shell variable to gnuplot

Hi I am plotting a series of CDFs using gnuplot using plot "data" u 1:(1./x.) smooth cumulative I am doing this over many files and I need to tune the x value to the number of lines that meets a particular condition. Is it possible to get the line count from shell using cat file | grep... (7 Replies)
Discussion started by: jamie_123
7 Replies

6. Shell Programming and Scripting

unable to pass value to user prompt from calling shell script

This is my script structure main script calls configure script which needs to be run as a different user and the configure script calls my application installation script. the application instruction script prompts the user for a directory which I need to pass from my main or configure script. ... (4 Replies)
Discussion started by: cmastays
4 Replies

7. Shell Programming and Scripting

How to pass current year and month in FOR LOOP in UNIX shell scripting?

Hi Team, I have created a script and using FOR LOOP like this and it is working fine. for Month in 201212 201301 201302 201303 do echo "Starting the statistics gathering of $Month partitions " done But in my scripts the " Month " variable is hard-coded. Can you please any one... (3 Replies)
Discussion started by: shoan
3 Replies

8. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

9. Shell Programming and Scripting

Unable to pass send command in shell script

I am trying to automate a testcase . I am installing some software and it waits for user input after displaying "Do you want to continue ? " I am trying to do this in shell scripting. #!/bin/bash #!/usr/bin/expect -f /usr/bin/expect << EOF spawn apt-get install openjdk-7-jdk expect "*Do you... (1 Reply)
Discussion started by: Abdul Navaz
1 Replies

10. Shell Programming and Scripting

Unable to pass value from .Shell script to .SQL file

Hi All, I am new to shell script. I am trying to pass value from .sh file to .sql file . But I am able to run the .sql file from .sh file with values in sql file. But I am unable to pass the values from .sh file. can some one please help to resolve this. here is my .sh file s1.sh ... (4 Replies)
Discussion started by: reddy298599
4 Replies
syslog.conf(4)						     Kernel Interfaces Manual						    syslog.conf(4)

NAME
syslog.conf - syslogd configuration file SYNOPSIS
facility.severity destination Where: Is part of the system generating the message, specified in /usr/include/sys/syslog_pri.h. See also the syslogd(8) reference page. The severity level, which can be emerg, alert, crit, err, warning, notice, info, or debug. See /usr/include/sys/syslog_pri.h. The syslogd daemon logs all messages of the specified severity level plus all messages of greater severity. For example, if you specify level err, all messages of levels err, crit, alert, and emerg or panic are logged. A local file pathname to a log file, a host name for remote logging or a list of users. In the latter case the users will receive messages when they are logged in. An asterisk (*) causes a message to be sent to all users who are currently logged in. DESCRIPTION
The /etc/syslog.conf file is a system file that enables you to configure or filter events that are to be logged by syslogd. You can specify more than one facility and its severity level by separating them with semicolons. You can specify more than one facility logs to the same file by separating the facilities with commas, as shown in the EXAMPLES section. The syslogd daemon ignores blank lines and lines that begin with an octothorpe (#). You can specify # as the first character in a line to include comments in the file or to disable an entry. The facility and severity level are separated from the destination by one or more tab characters. If you want the syslogd daemon to use a configuration file other than the default, you must specify the file name with the following com- mand: # syslogd -f config_file Daily Log Files You can specify in the /etc/syslog.conf file that the syslogd daemon create daily log files. To create daily log files, use the following syntax to specify the path name of the message destination: /var/adm/syslog.dated/ { file} The file variable specifies the name of the log file, for example, mail.log or kern.log. If you specify a /var/adm/syslog.dated/file path name destination, each day the syslogd daemon creates a sub-directory under the /var/adm/syslog.dated directory and a log file in the sub-directory, using the following syntax: /var/adm/syslog.dated/ date / file Where: The date variable specifies the day, month, and time that the log file was created. The file variable specifies the name of the log file you previously specified in the /etc/syslog.conf file. The syslogd daemon automatically cre- ates a new date directory every 24 hours and also when you boot the system. The current directory is a link to the latest date directory. To get the latest logs, you only need to reference the /var/adm/syslog.dated/current directory. EXAMPLES
The following is a sample /etc/syslog.conf file: # # syslogd config file # # facilities: kern user mail daemon auth syslog lpr binary # priorities: emerg alert crit err warning notice info debug # kern.debug /var/adm/syslog.dated/kern.log user.debug /var/adm/sys- log.dated/user.log daemon.debug /var/adm/syslog.dated/daemon.log auth.crit;syslog.debug /var/adm/syslog.dated/syslog.log mail,lpr.debug /var/adm/syslog.dated/misc.log msgbuf.err /var/adm/crash.dated/msgbuf.savecore kern.debug /var/adm/messages kern.debug /dev/console *.emerg * FILES
/etc/syslog.conf /etc/syslog.auth - Authorization file for remote logging. /usr/include/sys/syslog_pri.h - Common components of a syslog event log record. RELATED INFORMATION
Commands: /usr/sbin/syslogd(8), /usr/sbin/binlogd(8) System Administration delim off syslog.conf(4)
All times are GMT -4. The time now is 04:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy