dmulyalin / ttp

Template Text Parser
MIT License
350 stars 34 forks source link

how to put hostname in the filename output template? #41

Closed Raul-Flores closed 3 years ago

Raul-Flores commented 3 years ago

hi, i have one cuestion its possible put the hostname in filename (excell template o maybe other template)?

for example:

{{interface}} {{ ip_address }} YES {{method}} {{ status}} {{protocol | _line_}}

<output format="excel" returner="file" filename="%hostname%Y-%m-%d%H-%M-%S" #hostname for the device and date. url="./Excel_Outputs/" load="yaml"

table:

  • headers: interface, ip_address, method, status, protocol path: table key: interface tab_name: interfaces

thanks....

dmulyalin commented 3 years ago

Hi, sorry, but that is not supported.

However, coded support and now its available starting from 20f93c120313a705c42e8089b703b6eaf98315cc commit.

Docs - https://ttp.readthedocs.io/en/latest/Outputs/Returners.html#file

Feel free to install from master and test.

dmulyalin commented 3 years ago

@Raul-Flores Have you had a chance to test it? Does it works as expected?

paramountk commented 3 years ago

Hi,

I was looking for similar also and saw that it was requested. I tried it and have it working, but it seems to have changed the url behaviour. Now the url goes into the filename and does not modify the dir.

I have this configured:

<output format="excel" returner="file" filename= "{hostname_var}PSU%Y-%m-%d%H-%M-%S.xslx" url="./Output" load="yaml"

But, the file gets put in root directory - ie not in ./Output, and the filename shows as:

OutputhostA_PSU2021-01-28_22-26-10.xslx But the word Output is now added at the beginning of the filename.

Happy to test further, Thanks K

dmulyalin commented 3 years ago

Thank you @paramountk ,

File returner should be fixed starting with commit 544d2633a05c5dde7abd39a5d014f2efa5b04c45, the problem was with url="./Output", while url="./Output/" worked fine.

paramountk commented 3 years ago

Excellent, thanks - all working now :-)

dmulyalin commented 3 years ago

Thanks for the feedback, closing it.