How to make command line -e working in linux, this is basic

Hi All

I have a conf file, below is the example
When i run this in linux machine with a .conf file file, it work perfectly with command line -f

`

.logstash --debug -f test.conf

`

below is the conf file

> input {
> elasticsearch {
> hosts => ["localhost.com:9200"]
> ssl => true
> ssl_certificate_verification => false
> user => "abcd"
> password => "xyz"
> index => "testing"
> size => 10
> }
> }
> 
> filter {
> 
> 
> }
> 
> output {
> stdout { codec => rubydebug }
> 
> s3{
> access_key_id => "sddsdsdsdsd"
> secret_access_key => "sdsdsdsdsddsdsdsdsdds"
> region => "ap-south-1"
> bucket => "trial"
> size_file => 1234
> time_file => 15
> 
> }
> }

but when i run the same content with command line flag like this -e, it does not work

i am just converting the whole content of my conf file from to a single command like below, i get different error.

Do i need to escape each and every line?
Do we have a better solution to just use the conf file directly with command line flag -e

So i dont have to escape each /n, "", '' etc. How to fix this issue , any idea?

logstash --log.level debug -e "input { elasticsearch { hosts => ["localhost.com:9200"] ssl => true ssl_certificate_verification => false user => "abcd" password => "xyz" index => "testing" size => 10 } } filter { } output { stdout { codec => rubydebug } s3{ access_key_id => "sddsdsdsdsd" secret_access_key => "sdsdsdsdsddsdsdsdsdds" region => "ap-south-1" bucket => "trial" size_file => 1234 time_file => 15 } }"

Thanks

You can concatenate everything into a single line. You will need to escape every double quote if you use double quotes to surround the configuration, but you should be able to use single quotes around the configuration.

Okay, thanks for the response. What if i have xml tags with double quotes?
and by concatenate you mean , i should do join to make it single line?

Thanks

All of the double quotes would need to be escaped.

Yes, I mean the entire configuration can be a single line.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.