Sponsored Content
Top Forums Shell Programming and Scripting Keeping std & err outputs alive and feed one log file in a one-shot way Post 302734973 by Fundix on Friday 23rd of November 2012 07:45:56 AM
Old 11-23-2012
Question Keeping std & err outputs alive and feed one log file in a one-shot way

Bonjour,

I have a large script with a lot of print statements and misc commands. Standard and error outputs are redirected like into the following code :
Code:
#!/usr/bin/ksh

LOG=/<some dir>/log
> $LOG
exec >>${LOG} 2>>${LOG}

print aaaaa
print bbbbb
print ccccc
...
some_cmd

That way, standard and error outputs are added to the log file without appending >> {LOG} 2>>{LOG} after each print statement or command.

But now, we must execute these scripts via a new scheduler (VTOM) and still keep our ${LOG} file feeded.
The problem is that VTOM feeds its own logs with standard and error outputs so exec ... line must be commented.

My question : is there anyway to keep standard and error outputs alive for VTOM usage and feed too our UNIX log without appending redirections after each print statements and commands ?

ps : i've searched around tee command but without any good results. Maybe additional file descriptors may be used, but i've never worked with them.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect std out and std err to same file

Hi I want both standard output and standard error of my command cmd to go to the same file log.txt. please let me know the best commandline to do this. Thanks (2 Replies)
Discussion started by: 0ktalmagik
2 Replies

2. UNIX for Dummies Questions & Answers

Keeping cron jobs alive...?

Hi, I'm very new to Unix so please bear with me... :) Here is my requirement: I need to create a cron job to run two different scripts at 1 a.m. every day. Here's what I did: I used the "crontab -e" command and created a crontab file using the vi editor. When I exit the editor using... (3 Replies)
Discussion started by: yogiB
3 Replies

3. Shell Programming and Scripting

How to redirect std err and out to log file for multi-commands?

The following command does not work under cygwin bash. ant debug >log 2>&1 && ant image >>log 2>>&1 & pid=$! It gives the error "-bash: sysntax error near unexpected token '&'". Is there a way I can redirect std output and std error to file "log" for both the commands "ant debug" and "ant... (1 Reply)
Discussion started by: siegfried
1 Replies

4. Programming

Sun Studio C++ - Getting error in linking std::ostream &std::ostream::operator<<(std:

Hello all Im using CC: Sun C++ 5.6 2004/07/15 and using the -library=stlport4 when linkning im getting The fallowing error : Undefined first referenced symbol in file std::ostream &std::ostream::operator<<(std::ios_base&(*)(std::ios_base&))... (0 Replies)
Discussion started by: umen
0 Replies

5. Shell Programming and Scripting

How to store the outputs of a shell script inside a log file???

My shell script file name is test.sh and the contents of this test.sh file are ps_file="package1.ps" echo $ps_file ps_file1=`echo $ps_file| sed "s/.ps//g"` echo $ps_file1 ps2pdf -dSAFER -sPAPERSIZE=a4 /tmp/A380_RFS24/amm_r0_ps/$ps_file1.ps /tmp/A380_RFS24/amm_r0_pdf/$ps_file1.pdf Now i... (2 Replies)
Discussion started by: sunitachoudhury
2 Replies

6. Shell Programming and Scripting

filter input & outputs to another file

Hello All, I am stuck with the follwing problem , pls give me some advice.. Input file: input clock; input reset; \\reset all input yuv; //input comment output sur; output sud; output vtua; output tur; input ebi; //output comment The input file... (1 Reply)
Discussion started by: user_prady
1 Replies

7. Solaris

keeping a process alive ?

Hello guys, I have one script running that I need to keep it running 24x7 so I'd like to know how can I implement a sort of monitoring process I mean if for some reason this process dies somehow it gets automatically started again. Thanks. (8 Replies)
Discussion started by: cerioni
8 Replies

8. Shell Programming and Scripting

Ksh script: std Out/err

Hello gurus, this is part of my script: ls -1 ${MyFile} >> ${dir_log}ListFile${Now}.tmp FILENUM=`cat ${dir_log}ListFile${Now}.tmp| wc -l | awk '{print $1}'`>> /dev/null if then writeError "ERRORE: no file in directory for type ${FileName}!" >> ${LogFileName} Close 1 fi... (7 Replies)
Discussion started by: GERMANICO
7 Replies

9. Shell Programming and Scripting

ksh view std err state

I would like to know if a command works. "command" 2>/dev/null When I issue the command, the error is suppressed. How can I tell whether there was an error? (3 Replies)
Discussion started by: robin_simple
3 Replies
IPFM.CONF(5)							File Formats Manual						      IPFM.CONF(5)

NAME
ipfm.conf - IP Flow Meter configuration file DESCRIPTION
ipfm.conf is ipfm(8) configuration file. A hash mark (``#'') indicates that the end of the line is a comment and it will be ignored. The configuration rules will be interpreted from the end, and the first matching rule will be used, unless specified here. IPFM uses local and global variables, so it can manage multiple logs (different time delay, different hosts, different log filename ...) at the same time. Global variables will be used for all logs and local variables will only be used in the log being defined. GLOBAL VARIABLES
NETWORK DEVICE Syntax : DEVICE <device-name> <device-name> is the device on witch ipfm will log packets. IPFM monitors only one device. Time Coordinates Syntax : [UTC|local] This decides if IPFM will use UTC or local time in its outputs (log filename and the timestamp inside the file). Default is local. Note that IPFM works internally with UTC, and that the dates entered in the config file are UTC (see AFTER Syntax). NEW LOG Syntax : NEWLOG This creates a new log entry, where you can define new local variables. LOCAL VARIABLES
HOSTS TO LOG ipfm logs only specified hosts. Syntax: LOG [[NONE|FROM|TO|BOTH] <host>] [[NOT] WITH <host>] NONE do not log anything from or to this <host> FROM do log packets from this <host> TO do log packets to this <host> BOTH (default) do log packets from and to this <host> <host> can be : x.x.x.x : an IP. x.x.x.x/x.x.x.x : an IP followed by a subnet mask. WITH specifies if the packet is ignored (NOT WITH) or logged (WITH), in function of the second IP present in the packet. Examples : LOG 10.10.10.0/255.255.255.0 NOT WITH 10.10.10.1 will log any packets from or to hosts in subnet 10.10.10.0/255.255.255.0, except packets involving host 10.10.10.1 . LOG WITH 10.10.10.23 will log any packets in relation with host 10.10.10.23 LOG will log everything. OUTPUT TIME DELAY ipfm outputs its statistics every fixed period, with the ability to fix an exact time origin and offset, in Coordinated Universal Time (UTC). Syntax: DUMP EVERY <time> [AFTER <time>] <time> is composed of : <number> second(s) <number> minute(s) <number> hour(s) <number> day(s) Default DUMP time is 24 hours Default AFTER time is 0 seconds Examples: DUMP EVERY 30 minutes will dump the stats every 30 minutes at x:00 and x:30. DUMP EVERY 1 hour AFTER 7 minutes will dump the stats every hour, at 0:07, 1:07, 2:07, and so on, regardless of the time at which ipfm was launched. DUMP EVERY 1 day AFTER 14 hours will dump data every day, at 14:00:00 UTC (for France localtime (during the summer), at 16:00:00 +0200) CLEARING STATS You may want to clear your statistics sometimes, or after each dump. Syntax : CLEAR [ ALWAYS | NEVER | EVERY <time> [AFTER <time>] ] <time> is composed of : <number> second(s) <number> minute(s) <number> hour(s) <number> day(s) Default CLEAR mode is ALWAYS. Default AFTER time is 0 seconds. Note that both time values MUST be a multiple of the DUMP delay. Also, this line MUST come after the DUMP line. Examples CLEAR ALWAYS will clear the stats after every DUMP. CLEAR NEVER will never clear the stats, which means you are doing incremental statistics. CLEAR EVERY 30 minutes will clear the stats every 30 minutes at x:00 and x:30. Note that if your DUMP line had an AFTER value such as 3 minutes, this rule will clear the stats at x:03 and x:33. CLEAR EVERY 1 hour AFTER 10 minutes will clear the stats every hour, at 0:10, 1:10, 2:10, and so on. Note that if your DUMP line had an AFTER value such as 3 minutes, this rule will clear the stats at 0:13, 1:13, 2:13 and so on. LOG FILENAME Every delay, ipfm writes its output into a file, which name is specified by the rule FILENAME Syntax: FILENAME <filemask> <filemask> is a quoted string (eg. "/path/to/filename") that is parsed using strftime(3) syntax. Default FILENAME is /var/log/ipfm/%d-%b.%H-%M NOTE : The file will be overwritten without any check. REVERSE DNS You can activate or deactivate reverse DNS in the output file. WARNING : activating reverse DNS can delay a lot the production of the log file, due to DNS timeouts. Syntax : [RESOLVE|NORESOLVE] Default is NORESOLVE SORT OUTPUT FILE ipfm can sort output file depending on IN, OUT or TOTAL. Syntax : SORT IN|OUT|TOTAL Default is to sort nothing. Please note that this option could delay a bit the production of the log file. SET PROMISCUOUS MODE You can choose to log all packets on the network (default) or only packets which destination is your network device. This option could also be useful if you wish to set the promiscuous mode yourself (ifconfig eth0 [-]promisc), as the promisc mode is very badly handled under Linux. Please note that under Linux, if you run a program that sets the promiscuous mode (for example tcpdump), ipfm will also see its network interface set into promiscuous mode. Syntax [NO]PROMISC Default is PROMISC APPEND OR REPLACE LOG FILES You can choose to append the output to an existing logfile or to replace the old file by a new one. Syntax : APPEND|REPLACE Default is REPLACE SEE ALSO
strftime(3), ipfm(8) AUTHORS
Robert CHERAMY <tibob@via.ecp.fr> Andres KRAPF <dae@via.ecp.fr> Last change: 26 October 2000 IPFM.CONF(5)
All times are GMT -4. The time now is 04:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy