Yes, you can. The exec builtin can redirect file descriptors for an entire script, just like you'd redirect for external programs.
Code:
#!/bin/ksh
# Redirect the current stderr into stdout
exec 2>&1
# Redirect the current stdout into the log file
exec 1>timer_log.log
# Should end up in timer_log.log
echo "This is a message"
# Should also end up in timer_log.log
echo "This is an error message!" >&2
Hello,
I am writing this script in ksh (consisting of various functions such as -> read_file, write_file, pront_output and initialise) which basically process input files based on the parameters it contains.
My task now is to write any error conditions trapped by any of the function above to... (2 Replies)
Hi guys. Can someone point me to a resource that explains this? Basically these are websphere logs that need to be stored daily, I'm on sunOS 5.8. Each new file stored could have the current time as its filename. The script could be run on a cron which I can set up. I'm just not sure how to write... (0 Replies)
Dear all,
I'm new in Unix system, I need help about how to create execution file.
for example in my system i have file fg*
when i open fg file i get :
cmd='basename$0'
$cmd "$@"
how to create file like that (execution file) in KSH shell
thank you for your help
heru (4 Replies)
Accept command line input of a directory
keep a .logfile of the contents of the directory inputed
if a .logfile does not exist create one for the file that is missing a .logfile and create a message stating .logfile was updated
if all .logfiles are there display message stating all files are... (1 Reply)
Hi all,
I have about 15 directories all with exactly the same structure. I have a file in each of them called log.txt. This file sits in /home/ftp/*usernamehere*/ftptransfer/log/
Username here is the only change in each of the 15 directories.
I want to create a SIMPLE shell script that... (5 Replies)
Hi all,
I have a requirement to create a "superset" file out of a number of different sources with some different and some same columns.
We intend to have a manually updateable SuperSetCols.csv which would look like
"ColA","ColB","ColC","ColD","ColE","ColF","ColG"
so someday we may add... (3 Replies)
hi guys, trying to create a csv from a tricky log file in ksh,
using 'awk '{print $1" "$14" "$15" "$16" "$17" "$18" "$19}' >> $TMP_FILE' on another set of files I have an output file with hundreds of lines in which looks like so:
ABC_DEFGHI_16_JKLMNP11.20101115_095412_374.log:09:54:29.579... (3 Replies)
Newbie...Thank you for your help.
I am creating my first script that simply generates subdirectories to organize video, music, and text files within those subdirectories from my current working directory.
PROBLEM: I am trying to write a log file that contains, for each file, the original file... (0 Replies)
Hello Team-
we would like to implement an approach which has to write the log file simultaneously
when .sql file is executing by Unix process. At present,it is writing the log file
once the process is completed. I've tested the current process with the below
approaches and none of them... (1 Reply)
Discussion started by: Hima_B
1 Replies
LEARN ABOUT DEBIAN
inoticoming
INOTICOMING(1) INOTICOMING INOTICOMING(1)NAME
inoticoming - trigger actions when files hit an incoming directory
SYNOPSIS
inoticoming [ global-options ] directory actions*
DESCRIPTION
Inoticoming is a daemon to watch a directory with Linux's inotify framework and trigger actions once files with specific names are placed
in there.
For example it can be used to wait for .changes files uploaded into a directory and call reprepro to put them into your repository.
GLOBAL OPTIONS --foreground
Do not fork, but stay in the foreground and log to stderr.
--logfile filename
After forking in the background, log to the specified filename instead of syslog.
--pid-file filename
Write the pid of the running instance into filename.
--initialsearch
First search the directory for files already existing and process them with the given rules as if they just appeared. If files show
up in this inital phase, they may be processed twice, but should never be missed. (Unless they are too many and the inotify queue
overflows).
ACTIONS
Each action description is an optional list of options for this action (which files to call it for, what directory to change into before
executing it, ...), followed by the command and its arguments ended with a single ; as argument. Like:
inoticoming --foreground / --regexp ^v echo There appeared {} in the root directory. ; (Note that the before the ; is needed if and only
if you calling it from a shell or anything else interpreting the ; on its own).
ACTION OPTIONS
--prefix string
Only trigger this action, if the filename starts with the specified string.
--suffix string
Only trigger this action, if the filename ends with the specified string.
--regexp regular expression
Only trigger this action, if the filename matches the specified regular expression.
--chdir directory
Change into directory before executing the specified commands. (Note that since it is a well-behaved daemon, its working directory
is / which will be inherited by all actions).
--stdout-to-log
Redirect the command's output (stdout) to the logfile.
--stderr-to-log
Redirect the command's error output (stderr) to the logfile.
EXAMPLES
inoticoming --logfile logs/ilog --pid-file pid $INCOMINGDIR --suffix .changes --stderr-to-log reprepro -s -b $REPREPROBASEDIR --waitforlock
1000 processincoming rulename {} ;
This will call reprepro for every new .changes file. Note that giving {} as argument to processincoming (which inoticoming will
replace with the filename) so that only that .changes file is processed and reprepro will not complain about a possible other yet
incomplete .changes file is only available starting with reprepro version 2.2.2.
PROBLEMS
There is no handling of queue overflows yet.
REPORTING BUGS
Report bugs or wishlist requests to the Debian BTS
(e.g. by using reportbug inoticoming under Debian)
or directly to <brlink@debian.org>.
COPYRIGHT
Copyright (C) 2007 Bernhard R. Link
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
inoticoming 2007-08-18 INOTICOMING(1)