pmcmicha
Technical User
- May 25, 2000
- 353
I have a gawk statement which runs some commands via system and then if they fail I have the error redirection going to another file, but nothing is being written into this file...and I am curious as to why. Could someone please review the following syntax.
COPYDIR() {
export DIR # This has to be exported or awk will not know what it is....
echo ${2}|/usr/bin/gawk -v NUM="${NUM}" -v COUNT="${COUNT}" -v CNT="${1}" -v SDI
R="${2}" -v YR1="${YR1}" -v BDIR="${BDIR}" -v N="${N}" -F"_" '{for (i=CNT; i <=
(NF - NUM); i++)
{(N = YR1 "_" $i "/" BDIR);
printf strftime("%T"
printf("\tNow copying files from %s to %s.....",SDIR,N);
{ if (system("/usr/bin/cp -rp ${DIR}/* 1> DIAGERR 2>&1 " N "/" != 0) {
printf("Failed!!!\n"
} else {
printf("Done.\n"}}}}';
}
Thanks in advance.
COPYDIR() {
export DIR # This has to be exported or awk will not know what it is....
echo ${2}|/usr/bin/gawk -v NUM="${NUM}" -v COUNT="${COUNT}" -v CNT="${1}" -v SDI
R="${2}" -v YR1="${YR1}" -v BDIR="${BDIR}" -v N="${N}" -F"_" '{for (i=CNT; i <=
(NF - NUM); i++)
{(N = YR1 "_" $i "/" BDIR);
printf strftime("%T"
printf("\tNow copying files from %s to %s.....",SDIR,N);
{ if (system("/usr/bin/cp -rp ${DIR}/* 1> DIAGERR 2>&1 " N "/" != 0) {
printf("Failed!!!\n"
} else {
printf("Done.\n"}}}}';
}
Thanks in advance.