Adding custom mesg. when redirecting "exec 2>stderr.err" ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding custom mesg. when redirecting "exec 2>stderr.err" ?
# 1  
Old 07-10-2008
Adding custom mesg. when redirecting "exec 2>stderr.err" ?

Doubt regarding using "exec" command to redirect the STDERR to a file.
e.g I did it this way.

mystage.sh

#!/bin/sh exec 2>stage.err
....

....

cat stage.err
mv: cannot move `/root/stage' to a subdirectory of itself, `/root/stage_old/stage'
ls: *.zDB: No such file or directory

................
Now I want to add some timestamp details and some line indetations for this error log along with the redirection.
How should I do that ? Is there any method for that ?

Can you help me out. I want the error file to be as below

cat stage.err

Timestamp :30-06-08-01:39:10
-----------------------------------------------------------------------------------------------------------------
mv: cannot move `/root/stage' to a subdirectory of itself, `/root/stage_old/stage'

-----------------------------------------------------------------------------------------------------------------

Timestamp :30-06-08-01:39:12
-----------------------------------------------------------------------------------------------------------------
ls: *.DB: No such file or directory
-----------------------------------------------------------------------------------------------------------------
Kindly help me in this regard !!!

Thanks
Shankar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Post Here to Contact Site Administrators and Moderators

Suggestion: adding two new groups "sed" and "awk"

Majority of the questions are pertaining file/string parsing w.r.t sed or awk It would be nice to have these two as their own sub category under shell-programming-scripting which can avoid lot of duplicate posts. (1 Reply)
Discussion started by: jville
1 Replies

3. Shell Programming and Scripting

Redirect stdout/stderr, except e.g. "STRING"

Hi, I'm running a program (Python) whose output I would like to redirect to a log. But the program calls a library (that I cannot change), which outputs all sorts of useless information. I would like to redirect all output from my Python program into this log, except output that matches the... (7 Replies)
Discussion started by: rswindle
7 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Programming

Adding custom ("Hello") system call: help

I'm trying to add a custom ("Hello world" :o) system call. In /usr/src/linux/hello/ I put simple hello.c ...#include "linux/linkage.h" // for linking a system call #include "linux/kernel.h" // for "printk" asmlinkage int sys_hello() { printk(KERN_ALERT "Hello!"); return 1; }... and in... (5 Replies)
Discussion started by: courteous
5 Replies

6. Shell Programming and Scripting

tar "--totals" writes to stderr not stdout?

I want to use the "--totals" option in GNU tar for some reporting, however I have discovered that it writes the output to stderr not stdout and I would like to know why. This is running from BASH. mkdir /tmp/test touch /tmp/test/foo.file cd /tmp/ tar --totals -clpzf test.tar.gz test 2>... (2 Replies)
Discussion started by: jelloir
2 Replies

7. Shell Programming and Scripting

Why stderr file descriptor redirection makes ksh's "select" construct hang.

I am trying to use one global declaration --> "exec 2>$ERR" to capture all stderr outputs that may occur anywhere in my script. Then close it at the end of the script using --> "exec 2<&-" I am using KSH on Solaris 8. KSH Version M-11/16/88i If I comment two "exec .." statements in the... (11 Replies)
Discussion started by: kchinnam
11 Replies

8. UNIX for Dummies Questions & Answers

Using "find" and "-exec rm" ... Just no luck :(

Hi All, Ok, so I'm fairly new to Unix, but would like to think I'm grasping things fairly ok (Well until now ;) ), BUT with this one I'm going in circles ... LOL .. really can't work out why? So sorry for this post if it seems a little "dumb" .. But here goes. In short I'd like to achieve the... (55 Replies)
Discussion started by: Dean Rotherham
55 Replies

9. UNIX for Advanced & Expert Users

Eth err: "3c501 device eth0 does not seem to be present"

HI, When I do 'service network restart' , I am getting the following error. "3c501 device eth0 does not seem to be present, delaying initialization" Can any one suggest me the cause/solution for this? When I do 'lspci' it is showing the ehternet card as " Ethernet controller"Marvell... (2 Replies)
Discussion started by: praveen_b744
2 Replies

10. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question