[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20050509: logging script output via ldmd.conf exec command
- Subject: 20050509: logging script output via ldmd.conf exec command
- Date: Mon, 09 May 2005 14:29:51 -0600
Hi Angelo,
> To: <address@hidden>
> From: "Alvarez, Angelo CIV NAVPACMETOCCEN JTWC" <address@hidden>
> Subject: logging script output via ldmd.conf exec command
> Organization: > NAVPACMETOCCEN/JTWC
> Keywords: 200505032047.j43KlHP3009221
The above message contained the following:
> Aloha. My ldmd.conf has the following line:
> exec "/usr/ldm/scripts/Ingest.ksh >> /usr/ldm/logs/ingest/ingest.log"
>
> Is this correct? I ask b/c the log file was not created when I =
> restarted ldm but was created when I run:
>
> /usr/ldm/scripts/Ingest.ksh >> /usr/ldm/logs/ingest/ingest.log at the =
> command line.
The above didn't work because EXEC entries in the LDM
configuration-file, ldmd.conf, are executed via the execvp() system-call
-- which doesn't understand shell redirection syntax (e.g., ">>"). One
solution is to pass the pathname of the logfile to the script as an
argument, e.g.,
exec "/usr/ldm/scripts/Ingest.ksh /usr/ldm/logs/ingest/ingest.log"
The script can then append to the logfile. For example, having the
following near the beginning of the script will redirect all
standard-output to the file named by the first argument:
exec >> $1
If you, instead, wanted to redirect standard-error to that file, then
you could have
exec 2>> $1
And if you wanted to redirect both the standard-output and standard-error
streams:
exec >> $1 2>&1
> Also wanted to verify that my Ingest.ksh script is configured correctly =
> to work with LDM b/c not all of my pqinsert logs are updating as =
> expected.
>
> Here is the source (note: all files are copied to a "backup" directory =
> just in case of problems):
>
> #!/bin/ksh
>
> input_dir=3D/comms_dir/ddn/fnoc/
> ls $input_dir
> echo "Input_Dir: $input_dir"
> GRIDLOG=3D/usr/ldm/logs/ingest/pqinsert.grid.log
> WMOLOG=3D/usr/ldm/logs/ingest/pqinsert.wmo.log
> NPOINTLOG=3D/usr/ldm/logs/ingest/pqinsert.npoint.log
>
> cd ${input_dir}
> while [ 1 ]
> do
> rm -f ${input_dir}/*BEGIN*
> for arg in `ls -1`
> do
> prefix=3D`echo $arg | cut -c1-4`
> prefix_grep=3D`echo $prefix | grep -i temp`
> if [ "XX" !=3D "X${prefix_grep}X" ]
> then
> echo "$arg is still coming in, will skip over it for now.."
> else
> if [ "XX" !=3D "X`echo $arg | grep GR1`X" ]
> then=20
> #echo "NGRID GR1 $arg"
> cp $arg /comms_dir/oldpsrfiles/$arg
> pqinsert -l $GRIDLOG -f NGRID $arg
> rm -f $arg
> elif [ "XX" !=3D "X`echo $arg | grep IDY | grep grb`X" ]
> then=20
> #echo "NGRID GRB $arg"
> cp $arg /comms_dir/oldpsrfiles/$arg
> pqinsert -l $GRIDLOG -f NGRID $arg
> rm -f $arg
> elif [ "XX" !=3D "X`echo $arg | grep jgsm | grep grib`X" ]
> then=20
> #echo "NGRID GRIB $arg"
> cp $arg /comms_dir/oldpsrfiles/$arg
> pqinsert -l $GRIDLOG -f NGRID $arg
> rm -f $arg
> elif [ "XX" !=3D "X`echo $arg | grep BUFtdp`X" ]
> then=20
> #echo "NPOINT $arg"
> cp $arg /comms_dir/oldpsrfiles/$arg
> pqinsert -l $NPOINTLOG -f NPOINT $arg
> rm -f $arg
> elif [ "XX" !=3D "X`echo $arg | grep AWN | grep TXT`X" ]
> then=20
> #echo "WMO TXT $arg"
> cp $arg /comms_dir/oldpsrfiles/$arg
> pqinsert -l $WMOLOG -f WMO $arg
> rm -f $arg
> elif [ "XX" !=3D "X`echo $arg | grep AWN | grep dat`X" ]
> then=20
> #echo "WMO DAT $arg"
> cp $arg /comms_dir/oldpsrfiles/$arg
> pqinsert -l $WMOLOG -f WMO $arg
> rm -f $arg
> else
> #echo "UNKNOWN $arg"
> mv $arg /comms_dir/oldpsrfiles/unknowns
> fi
> fi
> done
> sleep 10
> done
It looks like the above script uses the standard-output stream instead
of the standard-error stream. You might want to reconsider that
decision and do something like
echo 1>&2 "$arg is still coming in, will skip over it for now.."
This assumes that the standard-error stream has been redirected
someplace meaningful. By default, the standard-error stream of an
EXEC-ed process from the LDM configuration-file will be redirected
to "/dev/console" if possible and "/dev/null, otherwise, unless the
user specifies a logfile pathname to the rpc.ldmd program via the "-l"
argument (and the ldmadmin(1) doesn't).
> v/r
> angelo
>
> Angelo Alvarez
> System Administrator
> NAVPACMETOCCEN/JTWC
> https://www.npmoc.navy.mil
> email: address@hidden
> phone: 808.471.3645
[snip]
Regards,
Steve Emmerson
> NOTE: All email exchanges with Unidata User Support are recorded in the
> Unidata inquiry tracking system and then made publicly available
> through the web. If you do not want to have your interactions made
> available in this way, you must let us know in each email you send to us.