Changeset 4919 for trunk/tools
- Timestamp:
- Jan 10, 2001, 3:17:23 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/DailyBuild/odin32ftp.cmd
r3451 r4919 1 /* $Id: odin32ftp.cmd,v 1. 1 2000-04-27 11:32:25bird Exp $1 /* $Id: odin32ftp.cmd,v 1.2 2001-01-10 14:17:23 bird Exp $ 2 2 * 3 3 * Old FTP routines using only RexxFTP. 4 4 * 5 * Copyright (c) 1999-200 0knut st. osmundsen (knut.stange.osmundsen@mynd.no)5 * Copyright (c) 1999-2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no) 6 6 * 7 7 * Project Odin Software License can be found in LICENSE.TXT … … 17 17 do i = 1 to 7 18 18 sFile = 'odin32bin-'|| DATE(S); 19 sDelete = 'odin32bin-'|| DateSub 7(DATE('S'));19 sDelete = 'odin32bin-'|| DateSub(DATE('S'), 7); 20 20 sFileDbg = sFile || '-debug.zip'; 21 21 sDeleteDbg = sDelete || '-debug.zip'; … … 25 25 if (sLoc = '' | sLoc = 'os2') then 26 26 do 27 /* (sFile, sFileRemote, sDelete, sLockFile, sSite , sUser, sPasswd); */28 rc = putfunction(sFileDbg, '/daily/'sFileDbg, '/daily/'sDeleteDbg, 'os2-debug', 'ftp.os2.org' , 'user', 'xxxxxxxx');29 rc = putfunction(sFileRel, '/daily/'sFileRel, '/daily/'sDeleteRel, 'os2-release', 'ftp.os2.org' , 'user', 'xxxxxxxx');30 rc = putfunction('ChangeLog', '/daily/Changelog', '/daily/'sDeleteRel, 'os2-Change', 'ftp.os2.org' , 'user', 'xxxxxxxx');27 /* (sFile, sFileRemote, sDelete, sLockFile, sSite); */ 28 rc = putfunction(sFileDbg, '/daily/'sFileDbg, '/daily/'sDeleteDbg, 'os2-debug', 'ftp.os2.org'); 29 rc = putfunction(sFileRel, '/daily/'sFileRel, '/daily/'sDeleteRel, 'os2-release', 'ftp.os2.org'); 30 rc = putfunction('ChangeLog', '/daily/Changelog', '/daily/'sDeleteRel, 'os2-Change', 'ftp.os2.org'); 31 31 end 32 32 33 33 if (sLoc = '' | sLoc = 'netlabs') then 34 34 do 35 /* (sFile, sFileRemote, sDelete, sLockFile, sSite , sUser, sPasswd); */36 rc = putfunction(sFileDbg, '/odinftp/daily/'sFileDbg, '/odinftp/daily/'sDeleteDbg, 'netlabs-debug', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');37 rc = putfunction(sFileRel, '/odinftp/daily/'sFileRel, '/odinftp/daily/'sDeleteRel, 'netlabs-release', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');38 rc = putfunction('ChangeLog','/odinftp/daily/ChangeLog', '/odinftp/daily/'sDeleteRel,'netlabs-changelog', 'ftp.netlabs.org' , 'user', 'xxxxxxxx');35 /* (sFile, sFileRemote, sDelete, sLockFile, sSite); */ 36 rc = putfunction(sFileDbg, '/odinftp/daily/'sFileDbg, '/odinftp/daily/'sDeleteDbg, 'netlabs-debug', 'ftp.netlabs.org'); 37 rc = putfunction(sFileRel, '/odinftp/daily/'sFileRel, '/odinftp/daily/'sDeleteRel, 'netlabs-release', 'ftp.netlabs.org'); 38 rc = putfunction('ChangeLog','/odinftp/daily/ChangeLog', '/odinftp/daily/'sDeleteRel,'netlabs-changelog', 'ftp.netlabs.org'); 39 39 end 40 40 end … … 43 43 44 44 putfunction: procedure 45 parse arg sFile, sFileRemote, sDelete, sLockFile, sSite , sUser, sPasswd45 parse arg sFile, sFileRemote, sDelete, sLockFile, sSite 46 46 if stream(sLockFile,'c','query exists') = '' then 47 47 do … … 52 52 say sLockFile 53 53 say sSite 54 55 /* get password */ 56 sPasswdString = GetPassword(sSite); 57 if (sPasswdString = '') then 58 do 59 call failure rc, 'Can''t find userid/password for' sSite'.', -1; 60 return -1; 61 end 62 parse var sPasswdString sUser':'sPasswd; 54 63 /* 55 64 say sUser … … 58 67 say sSite':' sFile '-> ' sFileRemote; 59 68 rc = FtpSetUser(sSite, sUser, sPasswd); 60 if rc = 1 then 61 do 62 rc = FtpDelete(sFileRemote); 69 if (rc = 1) then 70 do 71 rc = 0; 72 if (DATE('B')//7 <> 5) then 73 rc = FtpDelete(sFileRemote); 63 74 rcPut = FtpPut(sFile, sFileRemote, 'Binary'); 64 75 if (rcPut <> 0) then … … 67 78 say sDelete ' - ' rc 68 79 rc = FtpLogoff(); 69 if rcPut = 0then80 if (rcPut = 0) then 70 81 'echo ok > ' || sLockFile; 71 82 else … … 94 105 return; 95 106 96 /* rexx */ 97 /* load rexxutils functions */ 107 108 109 110 111 /* 112 * Reads the password file (passwd) in the script directory to 113 * get a password and userid for a given site. 114 * 115 * Format of the passwd file is: 116 * <site> <user> <password> 117 * Lines starting with '#' is ignored. 118 * 119 * @param sSite name of the site. 120 * @returns String on the form '<userid>:<passwd>' if found. 121 * Empty string if not found. 122 */ 123 GetPassword: procedure; 124 parse upper arg sSiteToFind 125 parse source sd1 sd2 sScript 126 sPasswd = filespec('drive', sScript) || filespec('path', sScript)||'\passwd'; 127 128 rc = stream(sPasswd, 'c', 'open read'); 129 if (pos('READY', rc) <> 1) then 130 do 131 say 'failed to open ftp password file - rc='rc; 132 return ''; 133 end 134 135 sRet = ''; 136 do while (lines(sPasswd) > 0) 137 sLine = strip(linein(sPasswd)); 138 if (sLine = '' | substr(sLine, 1, 1) = '#') then 139 iterate; 140 141 parse var sLine sSite' 'sUser' 'sPassword' 'sDummy 142 sSite = translate(strip(sSite)); 143 sUser = strip(sUser); 144 sPassword = strip(sPassword); 145 if (sSite = '' | sPassword = '' | sUser = '') then 146 say 'warning! misformed password line!'; 147 if (sSite = sSiteToFind) then 148 do 149 sRet = sUser||':'||sPassword; 150 leave 151 end 152 end 153 call stream sPasswd, 'c', 'close'; 154 return sRet; 155 98 156 99 157 /** 158 * Finds date seven days ago. 100 159 * @returns yyyymmdd date 101 * @param iDate Date on the yyyymmdd format. 102 */ 103 DateSub7: procedure 104 parse arg iDate 105 106 iDayInMonth = substr(iDate, 7, 2); 107 iMonth = substr(iDate, 5, 2); 108 iYear = substr(iDate, 1, 4); 109 110 if (iDayInMonth > 7) then 111 return iDate - 7; 112 else 113 do 114 if iMonth > 1 then 160 * @param sDate Date on the yyyymmdd format. 161 * @param cDays Number of days to subtract. 162 * @remark Works only for dates between 1000-01-01 and 9999-12-31 163 * including the limits. 164 */ 165 DateSub: procedure 166 parse arg sDate, cDays 167 168 /* subtraction loop which updates sDate and cDays for each iteration. */ 169 do while (cDays > 0) 170 /* 171 * Get the day in month of sDate. 172 * Do a simple subtraction is this is higher than the number of days to subtract. 173 */ 174 iDayInMonth = substr(sDate, 7, 2); 175 if (iDayInMonth > cDays) then 176 return sDate - cDays; 177 178 /* 179 * Determin previous month and the number of days in it. 180 */ 181 iMonth = substr(sDate, 5, 2); 182 iYear = substr(sDate, 1, 4); 183 if (iMonth > 1) then 115 184 iPrvMonth = iMonth - 1; 116 185 else 117 186 iPrvMonth = 12; 118 119 select 120 when iPrvMonth = 4 | iPrvMonth = 6 | iPrvMonth = 9 | iPrvMonth = 11 then 121 iDaysInPrevMonth = 30; 122 123 when iPrvMonth = 2 then 124 do 125 if ((iYear // 4) = 0) & (((iYear // 400) <> 0) | ((iYear // 2000) = 0)) then /*?*/ 126 iDaysInPrevMonth = 29; 127 else 128 iDaysInPrevMonth = 28; 129 end 130 131 otherwise 132 iDaysInPrevMonth = 31; 133 end /* select */ 134 135 say iDaysInPrevMonth 136 if iMonth > 1 then 137 return iDate - (100 - iDaysInPrevMonth) - 7; 187 cDaysPrvMonth = DateGetDaysInMonth(iYear, iPrvMonth); 188 189 /* 190 * Update date and days left to subtract. 191 */ 192 cDays = cDays - iDayInMonth; 193 if (iMonth > 1) then 194 sDate = sDate - iDayInMonth - 100 + cDaysPrvMonth; /* last day of previous month */ 138 195 else 139 return iDate - 8869 - 7; 140 end 141 end 142 143 return 00010101; 196 sDate = sDate - iDayInMonth - 8869; /* last day of last year */ 197 end 198 199 return sDate; 200 201 /* 202 * Gets the number of days in a given month. 203 * @param iYear the year. 204 * @param iMonth the month. 205 */ 206 DateGetDaysInMonth: procedure 207 parse arg iYear, iMonth 208 209 select 210 when (iMonth = 4 | iMonth = 6 | iMonth = 9 | iMonth = 11) then 211 cDays = 30; 212 213 when (iMonth = 2) then 214 do 215 if ((iYear // 4) = 0) & (((iYear // 400) <> 0) | ((iYear // 2000) = 0)) then 216 cDays = 29; 217 else 218 cDays = 28; 219 end 220 221 otherwise 222 cDays = 31; 223 end /* select */ 224 return cDays; 225 226
Note:
See TracChangeset
for help on using the changeset viewer.