I have a Logstash cluster (8 machines) I use to parse a huge amount of data every morning. I want to automate the launching step of my process. To do this, I have a master I use to send commands to all the machines on my cluster. But here is my problem : I want to do everything from the master and for that I have to remotely execute a script and this script needs a parameter (a date) and I don't know how to pass this argument through the ssh + 'bash -s' < my_script.sh command
ssh -i something.pem user@ip 'bash -s' < start_logstash.sh $1
The start_logstash.sh script needs the $1 param to work and obviously the previous command doesn't work... This ssh command is included in a for loop that execute command on every machine I specified.
EDIT : I found a kind of "quick win" for my problem. I use this command in the initial script (not the start_logstash.sh) :
sed -i -r "s/([0-9]){8}/$1/g" start_logstash.sh
This set the date
variable in my script where $1
is obviously the argument I passed to principal.sh
. But I'm always looking for a more sexy way to do it using ssh directly