1

I want to run two commands together for zkCli.

zkCli addauth digest username:password && zkCli setAcl /zknode-path world:anyone:crdwa

I have already set the ACL value for a zknode, and want to revert it back. But running this command give, authentication is not valid. How to run these two commands in one session?

Varun Gupta
  • 1,419
  • 6
  • 28
  • 53

1 Answers1

0

I managed to run multiple commands in zkCli using heredoc format (see How does ` cat << EOF` work in bash?)

Insert this snippet into a bash file

TMPVAR="addauth digest username:password\nsetAcl /zknode-path world:anyone:crdwa"

/zookeeper-3.4.10/bin/zkCli.sh <<EOF
$(echo -e ${TMPVAR})
quit
EOF

First, we set TMPVAR with both commands you wanted to execute in a single zkCli session, with a \n delimiter between them

Then we evaluate TMPVAR into STDIN line by line and this will make zkCli execute command after command, and then finally execute quit

shays10
  • 509
  • 5
  • 18