Sponsored Content
Top Forums Shell Programming and Scripting Help with getting a Ctrl-C trap working w/ a piped tail -f... Post 302512558 by chatguy on Sunday 10th of April 2011 11:36:37 PM
Old 04-11-2011
MySQL [Solved] How do you get a "Ctrl-C trap" working w/ a piped "tail -f" ?

Hi All,

Although each line below seems to work by itself, I've been having trouble getting the Control-C trap working when I add the "|perl -pe..." to the end of the tail -f line, below.
(That |perl -pe statement basically just adds color to highlight the word "ERROR" while tailing a log file)

...Does anyone know how to make the 2 lines below co-exist together, so that the CTRL-C trap still works, below?
Code:
trap 'print "\033[2K\033[41;1mUSER STOPPED LOG TAIL";' ERR
tail -f /var/log/logfile.log |perl -pe 's/ERROR/\e[41;1m$&\e[0m/g'

Thank you so much for the help,
CG

Last edited by chatguy; 04-15-2011 at 02:29 AM.. Reason: [Solved]
 

10 More Discussions You Might Find Interesting

1. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies

2. UNIX for Advanced & Expert Users

trap ctrl c in shell script

how to trap the ctrl c in unix shell script my script is running in while loop it should not be terminate with ctrl c. if i press ctrl c while running script it shloud ignore the same. please healp.......... thanks in advance (2 Replies)
Discussion started by: arvindng
2 Replies

3. UNIX for Dummies Questions & Answers

why tail +n not working?

Hello at my home when i try tail +5 emp it works but when i try in my college it doesn't work! what can be the problem any idea? when i type man tail it gives me various options in which it's mentioned that tail +n can also work when you want to display from nth line. But... (3 Replies)
Discussion started by: salman4u
3 Replies

4. Shell Programming and Scripting

Trap not working in orphaned child processes

I've search the various posts in these forums, but have not come up with a solution to my problem. I have a parent process that calls a child script, runs it in the background and the parent finishes - without waiting for the child process to complete. Inside the child, a trap is issued to trap... (6 Replies)
Discussion started by: HobieCoop
6 Replies

5. Shell Programming and Scripting

trap CTRL-C problem

I am trying to trap CTRL-C, now the program I call has it's own exit message, I think this is the problem .. This is what I have now : function dothis { echo 'you hit control-c' exit } function settrap { trap dothis SIGINT } settrap until false; do ./ITGRecv.exe doneDoing this I... (2 Replies)
Discussion started by: Pmarcoen
2 Replies

6. Shell Programming and Scripting

Trap CTRL-C and background process

Hello, I have a script which copies via scp several large files to a remote server. What I want is that even if someone hits CTRL-C, the scp commands continues till the end. Here is what I wrote #! /bin/bash function testFunction { echo "COPY START" scp large.tar.gz... (11 Replies)
Discussion started by: RobertFord
11 Replies

7. Shell Programming and Scripting

stopping tail function after ctrl + c

say i have a statement like this in a script tail -f /opt/blah/blha/user.log > final.log if ;then cat final.log | grep -i "servicer_user" > service.log cat final.log | grep -i "logic_user" > logic.log fi echo "script completed" but when the script is running if i press ctrl + c the... (4 Replies)
Discussion started by: vivek d r
4 Replies

8. Linux

ctrl+c not working

Hi All, I have ran one command tail -f <filename> to view newly appended text to that file. When i was done i pressed ctrl+c command to stop it but to my suprise it didn't work. I then tried top command and pressed ctrl+c and it worked fine and command aborted. I then just checked the tail... (0 Replies)
Discussion started by: tushar_shah06
0 Replies

9. Shell Programming and Scripting

Trap command not working

Hi Folks - For some reason, my trap command is not working. It's placed just prior to a normal exit: #:: ------------------------------------------------------------------------ #::-- Script Name: LCM_Backup.sh #:: #::-- Description: This script leverages Utility.sh to perform LCM... (16 Replies)
Discussion started by: SIMMS7400
16 Replies

10. Shell Programming and Scripting

--killing backround Procs spawned from the parent script with Ctrl+C trap

Hello: Am trying to understand why the method #2 works but method #1 does not. For both methods, sending CTRL+C should kill both the Parent script & all of the spanwd background procs. Method #1: ========================== #!/bin/sh ctrl_c() { echo "** Trapped CTRL-C" ... (3 Replies)
Discussion started by: gilgamesh
3 Replies
mdlogd(1M)						  System Administration Commands						mdlogd(1M)

NAME
mdlogd - Solaris Volume Manager daemon SYNOPSIS
mdlogd DESCRIPTION
mdlogd implements a simple daemon that watches the system console looking for messages written by the Solaris Volume Manger. When a Solaris Volume Manager message is detected, mdlogd sends a generic SNMP trap. To enable traps, you must configure mdlogd into the SNMP framework. See . USAGE
mdlogd implements the following SNMP MIB: SOLARIS-VOLUME-MGR-MIB DEFINITIONS ::= BEGIN IMPORTS enterprises FROM RFC1155-SMI DisplayString FROM SNMPv2-TC; -- Sun Private MIB for Solaris Volume Manager sun OBJECT IDENTIFIER ::= { enterprises 42 } sunSVM OBJECT IDENTIFIER ::= { sun 104 } -- this is actually just the string from /dev/log that -- matches the md: regular expressions. -- This is an interim SNMP trap generator to provide -- information until a more complete version is available. -- this definition is a formalization of the old -- Solaris DiskSuite mdlogd trap mib. svmOldTrapString OBJECT-TYPE SYNTAX DisplayString (SIZE (0..255)) ACCESS read-only STATUS mandatory DESCRIPTION "This is the matched string that was obtained from /dev/log." ::= { sunSVM 1 } -- SVM Compatibility ( error trap ) svmNotice TrapTRAP-TYPE ENTERPRISE sunSVM VARIABLES { svmOldTrapString } DESCRIPTION "SVM error log trap for NOTICE. This matches 'NOTICE: md:'" ::= 1 svmWarningTrap TRAP-TYPE ENTERPRISE sunSVM VARIABLES { svmOldTrapString } DESCRIPTION "SVM error log trap for WARNING.. This matches 'WARNING: md:'" ::= 2 svmPanicTrap TRAP-TYPE ENTERPRISE sunSVM VARIABLES { svmOldTrapString } DESCRIPTION "SVM error log traps for PANIC.. This matches 'PANIC: md:'" ::= 3 END ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWlvma, SUNWlvmr | +-----------------------------+-----------------------------+ |Interface Stability |Obsolete | +-----------------------------+-----------------------------+ SEE ALSO
snmpdx(1M), attributes(5) SunOS 5.11 3 Jun 2004 mdlogd(1M)
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy