Re: bash: capturing the stdout/stderr of a cmd to system log?

From: <captgoodnight@acsalaska.net>
Date: Thu Jul 01 2004 - 10:04:52 AKDT

On Thursday 01 July 2004 09:25 am, Thomison, Lee wrote:
> If the copy is successful, the return value is zero.
> If the copy is not successful, for whatever reason, the return value is
> non-zero.
>
> -------------------------------------
>
> Test code:
>
> SOURCE_USERNAME=3Dbozo
> SOURCE_HOST=3Dstore
> SOURCE_DIR=3D/cygdrive/c/
> SOURCE_FILE=3Dsched.prn [or .prnxxx for fail test]
>
> DEST_DIR=3D~
>
> SourceSchedFile=3D$SOURCE_DIR/$SOURCE_FILE
> DestSchedFile=3D$DEST_DIR/sched.prn_`date +%Y-%m-%d-%H:%M`
> DestSchedLink=3D$DEST_DIR/sched.prn
>
> scp $SOURCE_USERNAME@$SOURCE_HOST:$SourceSchedFile $DestSchedFile
> echo $?
> exit
>
>
>
> Successful scp:
>
> bozo> ./fetch
> sched.prn 100% 120 0.0KB/s 00:00
> 0
>
> Unsuccessful scp:
>
> bozo> ./fetch
> scp: /cygdrive/c/sched.prnxxx: No such file or directory
> 1
>
> As an alternative, is there a way to redirect stdout and stderr to a
> variable in the bashscript, rather than a file?

I'm curious, what's the value of the output? Can any text be substituted for the common scp output?
-Like a simple message sent to syslog/file/mail/aunt judy mentioning success/faliure of the task.

#!/bin/sh
scp "$1" "$2" &>/dev/null
foo=$(echo $?)
if [ $foo = "0" ]; then
        logger "Success message"
else
        logger "Failure message"
fi

I don't remember any info of value from the execution of an scp job; just speed and success of failure.

bests,
eddie

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Thu Jul 1 10:04:53 2004

This archive was generated by hypermail 2.1.8 : Thu Jul 01 2004 - 10:04:55 AKDT