Reputation: 721
I want to have a folder which will contain various files which will replace default ones when bouncing the app.
For example. if I have a example1.csv
which is loaded in proc1.q
and example1.csv
's path is /a/b/c/example1.csv
I want to be able to put /a/b/temporary/example1.csv
which I can modify and if I bounce proc1.q
it will be picked up in my app.
I thought the best approach would be using $PATH
, but my files are not executables.
Another idea would be to create a mapping of file location and filename something like
file1.csv | /a/b/c/file1.csv
file2.csv | /a/b/c/file2.csv
file3.q | /a/b/file3.q
Any suggestions?
The reason for this is that I have certain files which change dynamically for each server the app is running on and I would like to commit daily to gitlab and keep track of the state of the app on each server.
Upvotes: 0
Views: 66
Reputation: 13657
If you have access to cmd line as you've suggested then you can use both .Q.def
and .Q.opt
to accept command line args with defaults. E.g
> cat test.q
show files:.Q.def[`file1`file2`file3!(`$"/a/b/c/file1.csv";`$"/a/b/c/file2.csv";`$"/a/b/file3.q")].Q.opt .z.x;
>
> q test.q
KDB+ 3.5 2020.11.27 Copyright (C) 1993-2020 Kx Systems
file1| /a/b/c/file1.csv
file2| /a/b/c/file2.csv
file3| /a/b/file3.q
q)\\
> q test.q -file1 /a/b/temporary/file1.csv -file3 /a/b/c/d/file3.q
KDB+ 3.5 2020.11.27 Copyright (C) 1993-2020 Kx Systems
file1| /a/b/temporary/file1.csv
file2| /a/b/c/file2.csv
file3| /a/b/c/d/file3.q
So you pass in overrides to the cmd line when you need them, otherwise you fall back to the defaults.
You could do something similar by setting environment variables prior to bouncing the instance and pulling in the env variables using getenv
- if they're blank then revert to defaults.
Upvotes: 0