Re: Klish 3 interactive script issue

10 views
Skip to first unread message

Serj Kalichev

unread,
Jun 2, 2025, 4:50:24 AMJun 2
to kl...@googlegroups.com
Hi

Try this:

<COMMAND name="exit" help="Exit">
        <ACTION sym="script" in="tty">#!/bin/bash
                echo "Do you really want to exit? (y/n)"
                read -s -N 1 input
                [[ "${input: 0:1}" == "y" ]]
        </ACTION>
        <ACTION sym="nav">exit</ACTION>
        <ACTION sym="printl">Exiting...</ACTION>
</COMMAND>

The COMMAND tag is alias for the ENTRY with type "/COMMAND".
The attribute "interactive=" now is not used.
The "exec_on=success" is used by default so it's not necessary to specify it.
My /bin/sh is link to /bin/dash but not /bin/bash so shebang "#!/bin/bash"is needed.
I use "read" command with "-s -N 1" options.

So this script always works for me.



30.05.2025 17:39, Aleksander Djuric пишет:
Hi everyone!

I want to implement the following script with Klish 3:

<ENTRY name="exit" help="Exit">
        <ENTRY name="COMMAND" purpose="ptype" ref="/COMMAND"/>
        <ACTION sym="script" interactive="true" in="tty">
                echo "Do you really want to exit? (y/n)"
                read input
                [[ "${input: 0:1}" == "y" ]]
        </ACTION>
        <ACTION sym="nav" exec_on="success">exit</ACTION>
        <ACTION sym="printl" exec_on="success">Exiting...</ACTION>
</ENTRY>

This script works sometimes, but required to type answer twice. Any ideas on how to make it work?

Thanks in advance!
--
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 visit https://groups.google.com/d/msgid/klish/ce43412e-eeef-4d1f-a631-59c9cb8cce14n%40googlegroups.com.


Message has been deleted

Aleksander Djuric

unread,
Jun 6, 2025, 3:54:34 AMJun 6
to klish
Hi Serj!

Many thanks for your help! I have found same solution too.
Bash is not needed besause read return only one symbol with '-n1'.
Here is the difference of the code:

                read -sn1 input
                [[ "$input" == "y" ]]

Best wishes!
понедельник, 2 июня 2025 г. в 11:50:24 UTC+3, Serj Kalichev:
Reply all
Reply to author
Forward
0 new messages