Advertisement
juliozaco

farum bajada ftp

Jun 14th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. ======================================================
  2. Se trata de bajar y subir los ficheros al ftp de farum
  3. ======================================================
  4. - subimos ficheros de pedidos
  5.  
  6. En los bajados hacemos:
  7. - logs errores fichero de pedidos avisar por email a la gente de compras y pasarlos a históricos y a su carpeta compras para que los vean cuando quieran
  8. - facturas avisamos que hay nuevas, y guardamos en sus carpetas correspondientes
  9. - acuerdos avisamos que hay nuevos, y guardamos en sus carpetas correspondientes
  10.  
  11. =============================================================================================
  12. Primero lo más facil que es el fichero que ejecuta el ftp, en mi caso se llama ftp_farum_conf:
  13. ==============================================================================================
  14. Se irá creando ficheros "semaforo" si hay nuevos ficheros facturas o de acuerdos para luego saber que hacer
  15.  
  16.  
  17. usuario
  18. contraseña
  19. cd /SUBIDA
  20. pwd
  21. binary
  22. prompt
  23. lcd carpeta_subida
  24. mput *.txt
  25. cd /BAJADA
  26. lcd carpeta_bajada
  27. mget *.txt
  28. mdelete *.txt
  29. cd /FACTURAS/ALT
  30. mget *.*
  31. mdelete *.*
  32. !if exist FA*.pdf echo "facturas nuevas en carpeta farum ALT">>farum_nuevas_facturas.txt
  33. !if exist FA*.pdf copy /y FA*.pdf carpeta_facturas_proveedores\farum\ALT
  34. !if exist FA*.pdf del /q FA*.pdf
  35. cd /FACTURAS/MRK
  36. mget *.*
  37. mdelete *.*
  38. !if exist FA*.pdf echo "facturas nuevas en carpeta farum MRK">>farum_nuevas_facturas.txt
  39. !if exist FA*.pdf copy /y FA*.pdf carpeta_facturas_proveedores\farum\MRK
  40. !if exist FA*.pdf del /q FA*.pdf
  41. cd /FACTURAS/MSD
  42. mget *.*
  43. mdelete *.*
  44. !if exist FA*.pdf echo "facturas nuevas en carpeta farum MSD">>farum_nuevas_facturas.txt
  45. !if exist FA*.pdf copy /y FA*.pdf carpeta_facturas_proveedores\farum\MSD
  46. !if exist FA*.pdf del /q FA*.pdf
  47. cd /FACTURAS/NND
  48. mget *.*
  49. mdelete *.*
  50. !if exist FA*.pdf echo "facturas nuevas en carpeta farum NND">>farum_nuevas_facturas.txt
  51. !if exist FA*.pdf copy /y FA*.pdf carpeta_facturas_proveedores\farum\NND
  52. !if exist FA*.pdf del /q FA*.pdf
  53. cd /FACTURAS/SNF
  54. mget *.*
  55. mdelete *.*
  56. !if exist FA*.pdf echo "facturas nuevas en carpeta farum SNF">>farum_nuevas_facturas.txt
  57. !if exist FA*.pdf copy /y FA*.pdf carpeta_facturas_proveedores\farum\SNF
  58. !if exist FA*.pdf del /q FA*.pdf
  59. cd /DOCUMENTACION/ACUERDOS
  60. rem mget *.*
  61. rem mdelete *.*
  62. !if exist cf*.pdf echo "acuerdos nuevos en la intranet">>farum_nuevos_acuerdos.txt
  63. !if exist cf*.pdf copy /y cf*.pdf carpeta_facturas_proveedores\farum\ACUERDOS
  64. !if exist cf*.pdf del /q cf*.pdf
  65. bye
  66.  
  67.  
  68.  
  69. ======================================================================================
  70. Y ahora el batch que se ejecuta en el servidor cada x minutos que lanza el ftp anterior
  71. =======================================================================================
  72.  
  73.  
  74. rem FARUMPLUS. SUBIMOS Y BAJAMOS FICHEROS
  75. ::
  76. :FARUM
  77. cd e:\v\pedidos_por_ftp
  78. :: borramos primero ficheros semaforo anteriores
  79. if exist carpeta_bajada\farum_nuevas_facturas.txt del /q carpeta_bajada\farum_nuevas_facturas.txt
  80. if exist carpeta_bajada\farum_nuevos_acuerdos.txt del /q carpeta_bajada\farum_nuevos_acuerdos.txt
  81. ::
  82. :: conexion ftp en el que subimos ficheros y bajamos todo facturas y acuerdos
  83. :FTP
  84. rem if not exist carpeta_subida\*.txt goto OKS
  85. if exist carpeta_subida\*.txt echo FARUM empezamos a subir fichero %date% %time%>>"carpeta_log\ftp_central_log.txt"
  86. ftp -s:carpeta_ftp\ftp_farum_conf2.txt ftp.eldefarum.org
  87. if exist carpeta_subida\*.txt echo FARUM terminamos de subir ficheros %date% %time%>>"carpeta_log\ftp_central_log.txt"
  88. ::
  89. :: movemos a histórico los pedidos subidos
  90. if exist carpeta_subida\*.txt copy /y carpeta_subida\*.txt carpeta_subida\his\*.*
  91. if exist carpeta_subida\*.txt del /q carpeta_subida\*.txt
  92. ::
  93. :OKS
  94. :: FARUMPLUS ahora tratamos los ficheros de bajada
  95. rem if not exist carpeta_bajada\*.txt goto FIN
  96. ::
  97. :: los correctos a historico del principal y de la intranet
  98. if exist carpeta_bajada\ST_0*.txt copy /y carpeta_bajada\ST_0*.txt carpeta_bajada\his\*.*
  99. if exist carpeta_bajada\ST_0*.txt copy /y carpeta_bajada\ST_0*.txt carpeta_compras
  100. if exist carpeta_bajada\ST_0*.txt del /q carpeta_bajada\ST_0*.txt
  101. ::
  102. :ERRORES
  103. :: los incorrectos aviso por email esperando 7 segundos por cada envio
  104. for %%l in (carpeta_bajada\ST_1*.txt) do (
  105. start carpeta_bajada\mandaemail.exe "Pedido a FARUM incorrecto no procesado_mirar adjunto" "lou@za.com,rub@za.com,nat@za.com,jul@za.com" "no" %%l
  106. ping -n 7 127.0.0.1 >nul
  107. )
  108. :: Y los paso a his
  109. if exist carpeta_bajada\ST_1*.txt copy /y carpeta_bajada\ST_1*.txt carpeta_bajada\his\*.*
  110. if exist carpeta_bajada\ST_1*.txt del /q carpeta_bajada\ST_1*.txt
  111. ::
  112. :FACTURAS
  113. :: FARUMPLUS nuevas facturas aviso por email
  114. if exist carpeta_bajada\farum_nuevas_facturas.txt start carpeta_bajada\mandaemail.exe "FARUM ha enviado nuevas facturas_Revisa adjunto" "teo@za.com,lau@za.com,jes@za.com,jul@za.com" "no" carpeta_bajada\farum_nuevas_facturas.txt
  115. ::
  116. :ACUERDOS
  117. :: FARUMPLUS nuevos acuerdos aviso por email
  118. if exist carpeta_bajada\farum_nuevos_acuerdos.txt start carpeta_bajada\mandaemail.exe "FARUM han llegado nuevos acuerdos con los laboratorios_Revisa intranet" "lou@za.com,nat@za.com,rub@za.com,jul@za.com" "no"
  119. :FIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement