Hi, I'm new to REXX but have been trying to piece together some code to manipulate USS directories. The MKDIR command under the ARCHIVE: procedure returns a RC(-20), but the MKDIR under the NEW_DIR: procedure executes flawlessly. I've tried just about everything. The only way I can get this code to work is if I remove the SYSCALL logic, which tells me that it has something to do with that???? Can anyone throw me a bone on this?
/* REXX */
/* TRACE A */
CALL CLEANUP
CALL NEW_DIR
EXIT(RC)
NEW_DIR:
/* Get yesterday's date DDMMMYYYY and create directory */
DT = SPACE(DATE(N,(DATE(B)-1),B),0)
UPPER DT
DIRECTORY="'/u/kjdy01/SAS/Perf/daily-reports/"DT"'"
mkdir DIRECTORY
RETURN
CLEANUP:
/* Check /daily-reports directory to see if we need to archive */
M=DATE(M)
/* UPPER M */
call syscalls 'ON'
address syscall
'readdir /u/kjdy01/SAS/Perf/daily-reports DAYS.'
call syscalls 'OFF'
IF SUBSTR(DAYS.3,3,3) ^= M THEN
CALL ARCHIVE
RETURN
ARCHIVE:
/* Create MMMYYYY directory in archive */
SD = SUBSTR(DAYS.3,3,7)
UPPER SD
DIRECTORY="'/u/kjdy01/SAS/Perf/archive-reports/"SD"'"
mkdir DIRECTORY
/* Move all day directories to archive directory */
D1="/u/kjdy01/SAS/Perf/daily-reports/*"
D2="/u/kjdy01/SAS/Perf/archive-reports/"SD
CMD="mv" D1 D2
CALL BPXWUNIX CMD
RETURN
/* REXX */
/* TRACE A */
CALL CLEANUP
CALL NEW_DIR
EXIT(RC)
NEW_DIR:
/* Get yesterday's date DDMMMYYYY and create directory */
DT = SPACE(DATE(N,(DATE(B)-1),B),0)
UPPER DT
DIRECTORY="'/u/kjdy01/SAS/Perf/daily-reports/"DT"'"
mkdir DIRECTORY
RETURN
CLEANUP:
/* Check /daily-reports directory to see if we need to archive */
M=DATE(M)
/* UPPER M */
call syscalls 'ON'
address syscall
'readdir /u/kjdy01/SAS/Perf/daily-reports DAYS.'
call syscalls 'OFF'
IF SUBSTR(DAYS.3,3,3) ^= M THEN
CALL ARCHIVE
RETURN
ARCHIVE:
/* Create MMMYYYY directory in archive */
SD = SUBSTR(DAYS.3,3,7)
UPPER SD
DIRECTORY="'/u/kjdy01/SAS/Perf/archive-reports/"SD"'"
mkdir DIRECTORY
/* Move all day directories to archive directory */
D1="/u/kjdy01/SAS/Perf/daily-reports/*"
D2="/u/kjdy01/SAS/Perf/archive-reports/"SD
CMD="mv" D1 D2
CALL BPXWUNIX CMD
RETURN