$! 27 September 2006. SMS. $! $! Reset the attributes of a BACKUP save set file which have been $! changed by an FTP or HTTP file transfer. $! $! Most HTTP clients (Web browsers and the like) will create a $! Stream_LF file. Most FTP clients (doing a binary transfer) will $! create a 512-byte fixed-length record file. This procedure $! attempts to reset the file's attributes back to the original $! record format and length. This procedure uses SET FILE $! /ATTRIBUTE, which is not available before VMS V6.x. $! $! P1 = file spec. $! $ wso = "write sys$output" $! $! Verify the file name parameter. $! $ p1 = f$edit( p1, "trim") $ if (p1 .eqs. "") $ then $ cpr_name = f$environment( "procedure") $ cpr_name = f$parse( cpr_name, , , "name", "syntax_only") $ wso "" $ wso " Usage:" $ wso "" $ wso " @ ''cpr_name' save_set_file_spec" $ wso "" $ exit $ endif $! $ if (f$search( p1) .eqs. "") $ then $ wso " Can't locate file ""''p1'""." $ exit $ endif $! $! Check file format. $! $ rfm = f$file_attributes( p1, "RFM") $ if (rfm .eqs. "STMLF") $ then $ wso - " File record format is Stream_LF. The file's record format attribute" $ wso - " must be changed to fixed-512 before attempting the actual repair." $ read /error = fail /end_of_file = fail - /prompt = " Proceed? (y/n [n]): " sys$command ans $ ans = f$edit( ans, "TRIM") $ if (.not. ans) then goto fail $ set file /attributes = (rfm: fix, lrl: 512) 'p1' $ else $ if (rfm .nes. "FIX") $ then $ wso " Unexpected file record format: ''rfm'. Quitting." $ endif $ endif $! $ on error then continue $! $! Open the file, read the first record, and close the file. $! $ open /read ss_file 'p1' $ sts = $status $! $ if (.not. sts) then exit $! $ read ss_file record $ sts = $status $ close ss_file $! $ if (.not. sts) then exit $! $! Check the file record length. $! $ rec_len = f$length( record) $ if (rec_len .ne. 512) $ then $ wso " Original file record length (''rec_len') is not 512." $ wso " Confusion is possible." $ endif $! $! Extract the original record length from the data. $! $ rec_len = f$cvui( (40* 8), 32, record) $! $! Show the extracted value, and verify intent. $! $ wso " Original save set record length was ''rec_len'." $! $ read /error = fail /end_of_file = fail - /prompt = " Change attributes? (y/n) [n]: " sys$command ans $ ans = f$edit( ans, "TRIM") $! $! If requested, change the file attributes. $! $ if (ans) $ then $ wso " Setting file attributes..." $ set file /attribute = lrl: 'rec_len' 'p1' $ endif $! $ fail: $!