Ver Mensaje Individual
  #5
Antiguo 28 de diciembre de 2020, 20:15
JCantero
El Foro es mi casa
Activista del Foro: Activista del Foro - Issue reason: Por participación activa Agradecimientos: Por muchos agradecimientos de parte de los Foreros - Issue reason: Por muchos agradecimientos de parte de los Foreros 
Última Actividad 02.09.2026 00:15
Posts Posts: 442
Likes enviados Enviados: 167
Likes recibidos Recibidos: 269

Yo en linux lo hago con comandos del propio sistema.

En windows lo hago con un programa de cobol.

Me gusta hacer rutinas cuando no tengo algo estandard y fiable que funcione siempre sin depender de otros

Funciona con RM/Cobol y habria que adaptarlo para otros compiladores.
Si es de utilidad lo paso

---------- Post añadido : 20:15 ---------- Post anterior : 20:05 ----------

Código COBOL:
  1.        identification division.
  2.        program-id.  sibase64.
  3.      *
  4.      * CALL "sibase64" USING fichero fichero-dest
  5.      *  
  6.      * llamado desde windows por sivisors, en linux existe comando
  7.      *         ( jcantero )
  8.        environment division.                                                    
  9.        configuration section.                                                  
  10.        source-computer.  rmcobol-85.                                            
  11.        object-computer.  rmcobol-85.                                            
  12.        special-names.                                                          
  13.            decimal-point is comma.                                              
  14.      *                                                                        
  15.        input-output section.                                                    
  16.        file-control.                                                            
  17.      *                                                                        
  18.            select atr01 assign to random, nombre-atr01                          
  19.                   organization sequential                                  
  20.                   access mode is sequential                                    
  21.                   file status is fs-atr01.                                      
  22.            
  23.            select atr01j assign to random, nombre-atr01j                          
  24.                   organization sequential                                  
  25.                   access mode is sequential                                    
  26.                   file status is fs-atr01j.                                      
  27.            
  28.            
  29.                                                                                
  30.        
  31.        data division.
  32.        file section.                                                            
  33.      *                                                                        
  34.        fd  atr01.
  35.        01  reg-atr01.
  36.            02 atr-cabecera pic x(3).
  37.            
  38.        fd  atr01j.
  39.        01  reg-atr01j.
  40.            02 atr-cabeceraj pic x(4).
  41.        working-storage section.
  42.        01 nombre-atr01    pic x(80).                                            
  43.        01 nombre-atr01j    pic x(80).                                            
  44.        01 nombre-atr01jx    pic x(80).                                            
  45.        01 mensaje pic x(200).
  46.        
  47.        01 fs-atr01         pic xx.                                              
  48.               88 esta-atr01         value '00' '02'.                            
  49.               88 n-esta-atr01       value '23'.                                
  50.               88 fin-atr01          value '46'  '10'.                          
  51.               88 bloqueado-atr01    value '99'.                                
  52.               88 f-bloqueado-atr01  value '38' '93'.                            
  53.               88 f-noexiste-atr01   value '35'.                                
  54.        
  55.        01 fs-atr01j         pic xx.                                              
  56.               88 esta-atr01j         value '00' '02'.                            
  57.               88 n-esta-atr01j       value '23'.                                
  58.               88 fin-atr01j          value '46'  '10'.                          
  59.               88 bloqueado-atr01j    value '99'.                                
  60.               88 f-bloqueado-atr01j  value '38' '93'.                            
  61.               88 f-noexiste-atr01j   value '35'.                                
  62.        
  63.  
  64.        01  binary(2).
  65.            02  i                       pic 9(4).
  66.            02  j                       pic 9(4).
  67.            02  k                       pic 9(4).
  68.  
  69.        01  message-length              pic 9(6) binary.
  70.        01  base64-message-length       pic 9(6) binary.
  71.        01  triplet-count               pic 9(6) binary.
  72.        01  trailing-count              pic 9(6) binary.
  73.  
  74.  
  75.  
  76.        01  Base64-Alphabet             pic x(64) value
  77.                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
  78.                    "abcdefghijklmnopqrstuvwxyz" &
  79.                    "0123456789" &
  80.                    "+/".
  81.  
  82.        01  b64-triplet.
  83.            05  b64-4octets.
  84.                07                      pic x.
  85.                07  b64-3octets.
  86.                    09                  pic x.
  87.                    09  b64-2octets.
  88.                        11              pic x.
  89.                        11  b64-1octet  pic x.
  90.        01  redefines b64-triplet.
  91.            05  b64-octet           pic 999 binary(1) occurs 4.
  92.  
  93.        01  ARGUMENT-DESCRIPTION        BINARY(2).
  94.            02  ARGUMENT-TYPE           PIC 9(2).
  95.            02  ARGUMENT-LENGTH         PIC 9(8) BINARY(4).
  96.            02  ARGUMENT-DIGIT-COUNT    PIC 9(2).
  97.            02  ARGUMENT-SCALE          PIC S9(2).
  98.  
  99.        01  C-CARG-SUCCESS              PIC X.
  100.            88  IS-C-CARG-SUCCESS       VALUE "Y".
  101.        
  102.        01 carg usage binary.                                                    
  103.                  04 tipo pic 9(2).                                              
  104.                  04 longitudx pic 9(8) .                                        
  105.                  04 digitos pic 9(2).                                          
  106.                  04 escala pic s9(2).                                          
  107.        01 narg pic 9(3) binary.                                                
  108.        01 es-tipo pic x VALUE 'N'.                                              
  109.           88 es-tipo-ascii value 'y' 'Y'.                                      
  110.           88 es-tipo-num value 'n' 'N'.                                        
  111.        
  112.        linkage section.  
  113.        01 lk-par1 pic x.                                                        
  114.        01 lk-par1xx redefines lk-par1.                                          
  115.            03 lk-par1x pic x occurs 100.                                        
  116.        01 lk-par2 pic x.                                                        
  117.        01 lk-par2xx redefines lk-par2.                                          
  118.            03 lk-par2x pic x occurs 100.                                        
  119.        01 lk-par3 pic x.                                                        
  120.        01 lk-par3xx redefines lk-par3.                                          
  121.            03 lk-par3x pic x occurs 100.                                        
  122.        01 lk-par4 pic x.                                                        
  123.        01 lk-par4xx redefines lk-par4.                                          
  124.            03 lk-par4x pic x occurs 100.                                        
  125.                                                                                
  126. ------*                                                                        
  127.        PROCEDURE DIVISION using                                                
  128.               lk-par1 lk-par2 lk-par3 lk-par4.                                  
  129.                                                                                
  130. ------*                                                                        
  131.        declaratives.                                                            
  132.        errores section.                                                        
  133.            use after standard error procedure on  atr01 atr01j.
  134.        end declaratives.                                                        
  135.        programa section.                                                        
  136.        programa-prin.
  137.            initialize nombre-atr01 nombre-atr01j nombre-atr01jx                        
  138.            call 'c$narg' using narg                                            
  139.            end-call.      
  140.            if narg < 2 then go fin-p.
  141.            
  142.       d     accept narg update                                                      
  143.             call "c$carg" using es-tipo lk-par1 carg                            
  144.             end-call                                                            
  145.       d     accept longitudx update                                                                    
  146.             if longitudx > 80 move 80 to longitudx end-if
  147.             perform varying i from longitudx by -1 until i = 0                  
  148.                move lk-par1x(i) to nombre-atr01(i:1)                  
  149.             end-perform                                                        
  150.             call "c$carg" using es-tipo lk-par2 carg                            
  151.             end-call
  152.                                                                                
  153.             perform varying i from longitudx by -1 until i = 0                  
  154.                move lk-par2x(i) to nombre-atr01jx(i:1)                  
  155.             end-perform.                                                        
  156.        b.  
  157.             string nombre-atr01jx delimited by ' '
  158.                     'x' delimited by size into nombre-atr01j
  159.       d     display nombre-atr01 line 1.
  160.       d     display nombre-atr01j line 2
  161.       d     accept nombre-atr01jx line 3 update.
  162.            open input atr01
  163.            if not esta-atr01 then
  164.                    go fin-p
  165.            end-if.  
  166.            initialize i        
  167.            open output atr01j.
  168.        c.    
  169.            if not esta-atr01j then
  170.               display 'error ' line 1 position 1
  171.               accept fs-atr01j update
  172.               open output atr01j
  173.               close atr01j
  174.               open extend atr01j
  175.            end-if          
  176.            if not esta-atr01j then
  177.                    go fin-p
  178.            end-if.  
  179.  
  180.            initialize reg-atr01j reg-atr01j
  181.            read atr01 next record end-read
  182.            perform until fin-atr01
  183.                move all x"00" to b64-4octets
  184.                move reg-atr01 to  b64-3octets
  185.                call "C$LogicalShiftLeft"  using b64-4octets, 6
  186.                call "C$LogicalShiftRight" using b64-3octets, 2
  187.                call "C$LogicalShiftRight" using b64-2octets, 2
  188.                call "C$LogicalShiftRight" using b64-1octet,  2
  189.                perform varying j from 1 by 1
  190.                          until j > count of b64-octet
  191.                    add b64-octet (j), 1 giving k
  192.                    move Base64-Alphabet (k:1)
  193.                      to b64-octet (j) (1:1)    
  194.                end-perform
  195.                move b64-4octets to reg-atr01j
  196.                write reg-atr01j end-write
  197.                
  198.             initialize reg-atr01 reg-atr01j
  199.             read atr01 next record end-read
  200.            end-perform.
  201.  
  202.        fin-p.    
  203.            close atr01 atr01j.
  204.            initialize mensaje
  205.            string 'cmd /c type ' delimited by size
  206.                   nombre-atr01j delimited by ' '
  207.                   ' >> ' delimited by size
  208.                   nombre-atr01jx delimited by ' '
  209.                   into mensaje.
  210.            call 'ejecuta' using mensaje.
  211.            delete file atr01j.
  212.            
  213.            exit program.
  214.            
JCantero is offline   Responder Con Cita