batch
propósito
- Notas sobre el uso de scripts
bat
y colección de ellos
mover bitacora
- para crear el directorio del mes y mover los archivos de bitacora a ese directorio
C:\proyectos\hugo\notas-programacion>mkdir content\bitacora\2018\11
C:\proyectos\hugo\notas-programacion>move content\bitacora\2018-11-* content\bitacora\2018\11
Tomcat y proyecto
REM "PARA AUTOMATIZAR TAREAS"
REM "Lanzar desde el directorio donde esta el build.xml"
echo "PARANDO EL SERVIDOR"
call "c:\Servidores\Apache Tomcat 7.0.27\bin\shutdown.bat"
echo "PREPARANDO PROYECTO PARA DESPLEGAR"
call ant
echo "LANZANDO EL SERVIDOR"
echo "PROYECTO LISTO PARA DESPLEGAR"
call "c:\Servidores\Apache Tomcat 7.0.27\bin\startup.bat"
Exportación personal
REM TODOexportacionPersonal.bat
REM UN INTENTO DE AUTOMATIZAR TODA LA CARGA DE INTERINOS DESDE SIGI A EPLST
call set_java_path
"%JAVA_BIN%/java.exe" Exportacion ./conf/appPRI_1.properties
REM pause
"%JAVA_BIN%/java.exe" Exportacion ./conf/appPRI_2.properties
REM pause
"%JAVA_BIN%/java.exe" Exportacion ./conf/appPRI_3.properties
REM pause
"%JAVA_BIN%/java.exe" Exportacion ./conf/appPRI_4.properties
REM pause
"%JAVA_BIN%/java.exe" Exportacion ./conf/appPRI_5.properties
REM pause
"%JAVA_BIN%/java.exe" Exportacion ./conf/appPRI_6.properties
REM pause
REM "%JAVA_BIN%/java.exe" Exportacion ./conf/appSEC_1.properties
REM pause
REM "%JAVA_BIN%/java.exe" Exportacion ./conf/appSEC_2.properties
REM pause
REM "%JAVA_BIN%/java.exe" Exportacion ./conf/appSEC_3.properties
REM pause
REM "%JAVA_BIN%/java.exe" Exportacion ./conf/appSEC_4.properties
REM pause
REM "%JAVA_BIN%/java.exe" Exportacion ./conf/appSEC_5.properties
REM pause
REM "%JAVA_BIN%/java.exe" Exportacion ./conf/appSEC_6.properties
- para configurar las variables de entorno en java
REM seth_java_path.bat
REM set JAVA_HOME=C://Program Files (x86)//Java//jdk1.7.0_55
set JAVA_HOME=C://Program Files//Java//jdk1.7.0_25
set JAVA_BIN=%JAVA_HOME%/bin
set CLASSPATH=./classes/.;%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/jre/lib
SET CLASSPATH=%CLASSPATH%;./lib/log4j-1.2.14.jar
SET CLASSPATH=%CLASSPATH%;./lib/ojdbc6-11.2.0.3.jar
SET CLASSPATH=%CLASSPATH%;./lib/mail.jar
SET CLASSPATH=%CLASSPATH%;./lib/activation.jar
construir y desplegar sitios con Jekyll
REM lanza_pull_buidl_deploy.bat
@echo off
set horainicio=%TIME%
set mydate=%date:~6,4%%date:~3,2%%date:~0,2%
set log=log/log_%mydate%.log
echo Hora de inicio : %horainicio% >> %log%
call git status >> %log%
call git pull >> %log%
echo Hora despues de git pull : %TIME% >> %log%
call bundle exec jekyll build >> %log%
echo Hora despues de construir el sitio : %TIME% >> %log%
call aero deploy | find "Version" >> _data/versiones.yaml
rem /f para files el segundo token delimitado por espacio en blanco
rem del fichero data\versiones.yaml se escribe en data\version.yaml
rem en versiones estan las versiones generadas y en versio la actual
rem que es la que se lee desde el programa
for /F "tokens=2 delims= " %%a in (_data\versiones.yaml) do @echo version: %%a > "_data\sitio.yaml"
REM para quiter la simple barra de progreso
echo Hora de inicio : %horainicio% >> %log%
echo Hora de fin : %TIME% >> %log%
echo fechaCreacion: %date% - %time% >> "_data/sitio.yaml"
type _data/sitio.yaml >> %log%
echo fin >> %log%
REM pero quede subir el propio log generado
call git add -A
call git commit -m "el log de %date%"
call git push origin gh-pages
fecha y hora
call echo "lanzando el test inicio %DATE% - %TIME%"
construir y desplegar sitio con Hugo
REM lanzaGitHugoAero.bat
@echo off
set horainicio=%TIME%
set mydate=%date:~6,4%%date:~3,2%%date:~0,2%
set log=log/log_%mydate%.log
call git status >> %log%
call git add -A >> %log%
call git commit -m "automático javier-programacion %DATE%" >> %log%
call git push -u origin master >> %log%
echo Hora despues de git : %TIME% >> %log%
rd /s /q public
echo Borrado el directorio public : %TIME% >> %log%
call hugo >> %log%
echo Hora despues de construir el sitio : %TIME% >> %log%
call aero deploy | find "Version" >> data/versiones.yaml
rem /f para files el segundo token delimitado por espacio en blanco
rem del fichero data\versiones.yaml se escrie en data\version.yaml
rem en versiones estan las versiones generadas y en versio la actual
rem que es la que se lee desde el programa
for /F "tokens=2 delims= " %%a in (data\versiones.yaml) do @echo version: %%a > "data\sitio.yaml"
echo Hora de inicio : %horainicio% >> %log%
echo Hora de fin : %TIME% >> %log%
echo fechaCreacion: %date% - %time% >> data/sitio.yaml
type _data/sitio.yaml >> %log%
echo fin >> %log%
REM pero quede subir el propio log generado
call git add -A
call git commit -m "el log de %date%"
call git push -u origin master
mover los logs
- sacado de esta web
REM lanzarlo desde c:\logs\app\
REM crea el directorio viejos aunque no exista con los subdirectorios necesarios
@echo off
REM las variables son visibles dentro de LOCAL
SETLOCAL
For /f "tokens=1-3 delims=1234567890 " %%a in ("%time%") Do set "delims=%%a%%b%%c"
For /f "tokens=1-4 delims=%delims%" %%G in ("%time%") Do (
Set _hh=%%G
Set _min=%%H
Set _ss=%%I
Set _ms=%%J
)
:: Strip any leading spaces
Set _hh=%_hh: =%
:: Ensure the hours have a leading zero
if 1%_hh% LSS 20 Set _hh=0%_hh%
REM Echo The time is: %_hh%:%_min%:%_ss%
REM set miHora=%TIME%
REM set miFecha=%DATE%
REM echo %miHora%
REM echo %miFecha%
REM set hora=%TIME:~1,1%%TIME:~3,2%%TIME:~6,2%
set hora=%_hh%%_min%%_ss%%_ms%
set fecha=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
set directorio=c:\logs\app\viejos\epacf\logs_%fecha%_%hora%
echo el directorio es : %directorio%
mkdir %directorio%
move c:\logs\app\epacf\*201*.log %directorio%
ENDLOCAL&Set _time=%_hh%:%_min%