Sponsored Content
Top Forums Shell Programming and Scripting script to mail monitoring output if required or redirect output to log file Post 302719603 by rdrtx1 on Monday 22nd of October 2012 04:55:10 PM
Old 10-22-2012
try:
Code:
 
 lpar-command | awk '
/^Name/ { next; }
/^---/ { next; }
{
    state[$2] = state[$2] $1 " ";
    if( $2 == "A" )
        acount++;
    else
        others++;
}
END {
if (state["D"] ~ /./ || state["T"] ~ /./ || state["B"] ~ /./) {
  printf( "==== WPAR Status Check =====\n" );
  printf( "==== %s ====\n", date );
  printf( "**** WPAR state Active:\n\t%s\n", state["A"] );
  printf( "\t%d WPAR state A-Active\n\n", acount );
  printf( "**** WPAR state Defined/Transition/broken:\n\t%s %s %s\n", state["D"], state["T"], state["B"] );
  printf( "\t%d WPARs are in D-Defined/T-Transition/B-Broken state\n", others );
}
}
' date="$(date)" > temporary_log_file
[[ -s "temporary_log_file" ]] && cat temporary_log_file | mail-command

This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirect output to log file

hello all, I'm invoking the program generate-report using backticks from my perl program and redirecting the output to the log file sge-stderr.log. But when i check the process using ps command it is spawing two processes where the below code is parent process and the program generate-report as... (2 Replies)
Discussion started by: kalyanraj
2 Replies

2. Shell Programming and Scripting

redirect only the standard error output to mail

I'm writing a script using file descriptor 2 (std error) to send an email only if the command fails or errors out but the script always emails me irrepective of whether it fails or not. It will not email the /tmp/check.error file output if doesn't error out just the mail with the subject "Cannot... (3 Replies)
Discussion started by: barkath
3 Replies

3. Shell Programming and Scripting

Cronjob - Redirect mail output to file, LINES & COLUMNS

I currently have an expect script that issues the 'mail' command and sends an 'x' when it receives the & prompt from mail to quit. The expect script is able to do stty rows 100 columns 200 < $spawn_out(slave,name) to set up the number of columns and rows. I would like to get rid of the expect... (0 Replies)
Discussion started by: jharvey
0 Replies

4. Shell Programming and Scripting

how to redirect the output of a grep command to a file inside a shell script

hi, i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (11 Replies)
Discussion started by: kripssmart
11 Replies

5. Shell Programming and Scripting

Redirect an output from a script to a file and display it at a console simultaneously

Hi, I'd like to redirect the STDOUT output from my script to a file and simultaneously display it at a console. I've tried this command: myscript.sh | tail -f However, it doesn't end after the script finishes running I've also tried this: myscript.sh | tee ~/results.txt But it writes... (3 Replies)
Discussion started by: wenclu
3 Replies

6. Programming

How to redirect the output of a shell script to a file?

hi, i have a html form which call a perl program, this perl program calls a shell script. <html> <head> <title>demo</title> </head> <body> <form name="frm1" action="/cgi-bin/perl_script.pl" method="post"> <input type="text" name="fname"> ... (1 Reply)
Discussion started by: Little
1 Replies

7. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

8. UNIX for Dummies Questions & Answers

[Solved] How to Redirect Output To Log File?

I have the below script, but when i execute it is still printing to screen is there a way i can stop this and just print everything to the log file. Thank you. #!/bin/bash exec > >(tee "/var/log/ScriptLogs/called_from_incrontab.log") 2>&1 DIR="$1" FILE="$2" echo "STEP 1: Datafile... (5 Replies)
Discussion started by: Ariean
5 Replies

9. Shell Programming and Scripting

Redirect script output to file after grep

i have simple program that generate log file 1 line every sec, i need to do grep for specific record then redirect to another file. #!/bin/bash for i in `seq 1 20`; do echo $i sleep 1 done ./test.sh |egrep "5|10|15" 5 10 15 r ./test.sh... (2 Replies)
Discussion started by: before4
2 Replies

10. Shell Programming and Scripting

Required formatted output on mail for disk utilization

Hi Experts, Could you pls help with below query I have written below script to capture disk utilization and then send the output on mail. But getting unformated output on mail #!/bin/bash echo "Hi Sur,">dfoutput.csv printf '\n' >>dfoutput.csv echo "Please find BAYSQUAR2 filesystem... (4 Replies)
Discussion started by: as7951
4 Replies
tsalarm_get(3EXT)					    Extended Library Functions						 tsalarm_get(3EXT)

NAME
tsalarm_get, tsalarm_set - get or set alarm relays SYNOPSIS
cc [ flag... ] file... -ltsalarm [ library... ] #include <tsalarm.h> int tsalarm_get(uint32_t alarm_type, uint32_t *alarm_state); int tsalarm_set(uint32_t alarm_type, uint32_t alarm_state); PARAMETERS
alarm_type The alarm type whose state is retrieved or set. Valid settings are: TSALARM_CRITICAL critical TSALARM_MAJOR major TSALARM_MINOR minor TSALARM_USER user alarm_state The state of the alarm. Valid settings are: TSALARM_STATE_ON The alarm state needs to be changed to "on", or is returned as "on". TSALARM_STATE_OFF The alarm state needs to be changed to "off", or is returned as "off". TSALARM_STATE_UNKNOWN The alarm state is returned as unknown. DESCRIPTION
The TSALARM interface provides functions through which alarm relays can be controlled. The set of functions and data structures of this interface are defined in the <tsalarm.h> header. There are four alarm relays that are controlled by ILOM. Each alarm can be set to "on" or "off" by using tsalarm interfaces provided from the host. The four alarms are labeled as critical, major, minor, and user. The user alarm is set by a user application depending on system condition. LEDs in front of the box provide a visual indication of the four alarms. The number of alarms and their meanings and labels can vary across platforms. The tsalarm_get() function gets the state of alarm_type and returnsit in alarm_state. If successful, the function returns 0. The tsalarm_set() function sets the state of alarm_type to the value in alarm_state. If successful, the function returns 0. The following structures are defined in <tsalarm.h>: typedef struct tsalarm_req { uint32_t alarm_id; uint32_t alarm_action; } tsalarm_req_t; typedef struct tsalarm_resp { uint32_t status; uint32_t alarm_id; uint32_t alarm_state; } tsalarm_resp_t; RETURN VALUES
The tsalarm_get() and tsalarm_set() functions return the following values: TSALARM_CHANNEL_INIT_FAILURE Channel initialization failed. TSALARM_COMM_FAILURE Channel communication failed. TSALARM_NULL_REQ_DATA Allocating memory for request data failed. TSALARM_SUCCESS Successful completion. TSALARM_UNBOUND_PACKET_RECVD An incorrect packet was received. The tsalarm_get() function returns the following value: TSALARM_GET_ERROR An error occurred while getting the alarm state. The tsalarm_set() function returns the following value: TSALARM_SET_ERROR An error occurred while setting the alarm state. EXAMPLES
Example 1 Get and set an alarm state. The following example demonstrates how to get and set an alarm state. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <tsalarm.h> void help(char *name) { printf("Syntax: %s [get <type> | set <type> <state>] ", name); printf(" type = { critical, major, minor, user } "); printf(" state = { on, off } "); exit(0); } int main(int argc, char **argv) { uint32_t alarm_type, alarm_state; if (argc < 3) help(argv[0]); if (strncmp(argv[2], "critical", 1) == 0) alarm_type = TSALARM_CRITICAL; else if (strncmp(argv[2], "major", 2) == 0) alarm_type = TSALARM_MAJOR; else if (strncmp(argv[2], "minor", 2) == 0) alarm_type = TSALARM_MINOR; else if (strncmp(argv[2], "user", 1) == 0) alarm_type = TSALARM_USER; else help(argv[0]); if (strncmp(argv[1], "get", 1) == 0) { tsalarm_get(alarm_type, &alarm_state); printf("alarm = %d state = %d ", alarm_type, alarm_state); } else if (strncmp(argv[1], "set", 1) == 0) { if (strncmp(argv[3], "on", 2) == 0) alarm_state = TSALARM_STATE_ON; else if (strncmp(argv[3], "off", 2) == 0) alarm_state = TSALARM_STATE_OFF; else help(argv[0]); tsalarm_set(alarm_type, alarm_state); } else { help(argv[0]); } return 0; } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Uncommitted | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
libtsalarm(3LIB), attributes(5) SunOS 5.11 4 Sep 2007 tsalarm_get(3EXT)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy