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?
Something like pseudo-code:
$ scp blahblah 2>&1 >somevariable #$somevariable holds the string
output
$ echo $? #returns a numeric
$ logger $somevariable
------------------------------------
> try the following if you are interested in the return value of=20
> the last=20
> command. Don't quote me but I'm pretty sure all POSIX compliant
> apps=20
> must have a return value.
> # echo $?
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Thu Jul 1 09:25:28 2004
This archive was generated by hypermail 2.1.8 : Thu Jul 01 2004 - 09:25:30 AKDT