PARAM test condition

75 views
Skip to first unread message

Murat BÜLBÜL

unread,
Aug 12, 2023, 6:56:42 AM8/12/23
to klish
Hi all,

I want to enable one option under subcommand if previous parameter has no value. However, I already tested followings. It is not working.  

My second question is multi condition in test option? Can we able to add and(&&) or(||) conditions? I will be appreciated if you have any examples.  

Already tested below options:
test='"!${interface-value}"'
test='!"${interface-value}"'
test=' -z "${interface-value}"'
test='"${interface-value}" === null'
test='"${interface-value}" === undefined'

<PARAM name="interface"
help="Network interface name, such as eth0 or eth1 or eth1.112"
optional="true"
mode="switch"
ptype="SUBCOMMAND">
<PARAM name="interface-value"
prefix="--interface"
help="Network interface name, such as eth0 or eth1 or eth1.112"
ptype="INTERFACE_NAME"
completion="${network_interfaces}"/>
</PARAM>

<PARAM name="monitor-mode"
help="Monitoring mode"
mode="switch"
prefix="--mode"
ptype="SUBCOMMAND">
<PARAM name="general-statistics"
test='"!${interface-value}"'
help="Start the general interface statistics"
mode="subcommand"
ptype="SUBCOMMAND"/>
<PARAM name="ip-traffic"
help="Start the IP traffic monitor (use 'any' for all interfaces)"
mode="subcommand"
ptype="SUBCOMMAND"/>
<PARAM name="detailed-statistics"
help="Start the detailed statistics facility on an interface"
mode="subcommand"
ptype="SUBCOMMAND"/>
</PARAM>

Best regards.

Murat BÜLBÜL

unread,
Aug 12, 2023, 3:18:58 PM8/12/23
to klish
Hi again,

test option equal condition also not running. I am using klish 2.2.5 version. As i see, only not equal(!=) is running well.

test='"${monitor-mode}" == "general-statistics"'
test='"${monitor-mode}" === "general-statistics"'

12 Ağustos 2023 Cumartesi tarihinde saat 13:56:42 UTC+3 itibarıyla Murat BÜLBÜL şunları yazdı:

Murat BÜLBÜL

unread,
Aug 13, 2023, 6:50:28 AM8/13/23
to klish
I have found the following guide. Solved many things. 
https://code.google.com/archive/p/klish/wikis/conditional_param.wiki

12 Ağustos 2023 Cumartesi tarihinde saat 22:18:58 UTC+3 itibarıyla Murat BÜLBÜL şunları yazdı:

Serj Kalichev

unread,
Aug 14, 2023, 9:48:04 AM8/14/23
to kl...@googlegroups.com
"test" syntax is like command line utility "test"
so -a is "and"
-o is "or"

12.08.2023 13:56, Murat BÜLBÜL пишет:
--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/klish/cfd82b41-028c-4f88-b7d3-95f0480fd849n%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages