abbbi / abbbi/xtdcliconf

Automating switch-config-export via crontab/bash

Aperta
#1 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
2
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi, I'm having the following problem:
I have created a wrapper-script around your script to automate config-backups.
lets all it "runbackup.sh"

`#!/bin/bash`
`rm -f /opt/xtdcliconf/configs/*`
`/usr/bin/python3 /opt/xtdcliconf/xtdcliconf.py --host myswitch1 --user admin --password mysupersecretpassword --no-systemview --execute /opt/xtdcliconf/backup-config | /usr/bin/tee /opt/xtdcliconf/configs/myswitch1`

When I execute the bash-script in a running terminal I am able to capture the output with tee.
But: using cron it fails as following:

/etc/crontab:
`SHELL=/bin/bash`
`PATH=/sbin:/bin:/usr/sbin:/usr/bin`
`...`
`45 * * * * xtdcliconf /bin/bash -c "/opt/xtdcliconf/runbackup.sh" >> /var/log/myjob.log 2>&1`
`or`
`45 * * * * xtdcliconf /opt/xtdcliconf/runbackup.sh`
`or`
`45 * * * * root sudo -u xtdcliconf /opt/xtdcliconf/runbackup.sh`
`or`
`45 * * * * root /opt/xtdcliconf/runbackup.sh`

`
xtdcliconf:execute_xtd_cli(): Configured switch supports XTD CLI Cmd, switch to extended cli mode with cmd: "xtd-cli-mode"
xtdcliconf:execute_cmdfile(): executing commands from file: /opt/xtdcliconf/backup-config
Traceback (most recent call last):
File "/opt/xtdcliconf/xtdcliconf.py", line 204, in
interact.take_control()
File "/usr/local/lib/python3.6/site-packages/paramiko_expect.py", line 288, in take_control
original_tty = termios.tcgetattr(sys.stdin)
termios.error: (25, 'Inappropriate ioctl for device')
`

Already tried to switch to script instead of tee, using pipe for stdout-redirection, changed the cron-parameters, env-vars, "python -u", etc.
This seems to be a python-related issue.
Any idea on how to get around this or provide an optional command-parameter to save the config to a file?

Any help would be highly appreciated.

Best regards
Florian Jerusalem

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.