kafka-console-producer and bash script -


want send message bash script.

  bin/zookeeper-server-start.sh config/zookeeper.properties > zookeeper.log 2>&1 & sleep 2  bin/kafka-server-start.sh config/server.properties > server.log 2>&1 & sleep 2  #create topic bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic $1 sleep 2  #get topics list echo "kafka has next topics:" bin/kafka-topics.sh --list --zookeeper localhost:2181  #send message echo "will send messages:" bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $1 "test 1" 

kafka started well. , can send message producer console

 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $1 "test 1" 

but can't send message bash script. how can send bash script ?

thanks.

try doing this:

echo "test 1" | bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $1 

or this:

cat file.txt | bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $1 

Comments