34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
import subprocess
|
|
import sys
|
|
|
|
def main(output_file):
|
|
# Ejecutar el comando `listHardwareInfo.py` y capturar el resultado
|
|
try:
|
|
print(f"------------------------------------------ loading listHardwareInfo.py")
|
|
result = subprocess.run(
|
|
["python3", "/opt/opengnsys/scripts/listHardwareInfo.py"],
|
|
capture_output=True, text=True, check=True
|
|
)
|
|
output_lines = result.stdout.strip().split('\n')
|
|
file_path = output_lines[-1] # Obtener la última línea como la ruta del archivo de salida
|
|
print(f"------------------------------------------ archivo:{file_path}")
|
|
|
|
# Leer desde la segunda línea del archivo y escribir en el archivo de salida especificado
|
|
with open(file_path, 'r') as input_file, open(output_file, 'w') as output:
|
|
lines = input_file.readlines()[1:] # Saltar la primera línea
|
|
output.writelines(lines)
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
print("Error ejecutando listHardwareInfo.py:", e.stderr, file=sys.stderr)
|
|
sys.exit(e.returncode)
|
|
except FileNotFoundError as e:
|
|
print(f"Archivo no encontrado: {e.filename}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print("Uso: python3 InventarioHardware.py <archivo_salida>")
|
|
sys.exit(1)
|
|
main(sys.argv[1])
|