abbbi / abbbi/xtdcliconf

Automating switch-config-export via crontab/bash

Offen
#1 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
2
Forks
1
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.