Script Command Line Arguments - Kdb+ / qStudio

Home Forums Kdb+ / qStudio Script Command Line Arguments

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #133


    If I want to supply command line arguments to a .q script how can I do that?

    I have an end of day script that backs up data to a certain directory. I want to dynamically specify the location from a shell script.


    Hi Simon,

    For kdb command line arguments .z.f , .z.x and .Q.opt are the functions you want:

    C:\temp\dd>echo “show `p” > script.q

    C:\temp\dd>q script.q -p 5000 -mvar 101 -myString “hello world”
    KDB+ 3.0 2013.03.14 Copyright (C) 1993-2013 Kx Systems

    “show `p”
    q).z.f / filename of script loaded
    q).z.x / command line args
    “hello world”

    q).Q.opt .z.x / convert to dict
    mvar | “101”
    myString| “hello world”

    As you can see:
    .z.f – filename of script loaded at command line
    .z.x – string list of command line excluding q/script/kdb-specific-arguments
    .Q.opt – convert a list of strings to a dictionary

    • This reply was modified 11 years, 2 months ago by admin.

    More details on the q command line arguments can be found here:

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.