0

I created this bash script to run python code on each host listed in my ip_list:

#!/bin/bash

declare -a ip_list=('10.99.1.1' '10.99.1.2' '10.99.1.3"' '10.99.1.4');

for i in $(ip_list) ; do 
    ssh -i ~/Downloads/abc.pem -t -t ec2-user@$i "sudo   python /home/user/abc.py"
done

But I got error:

Error: line 4: ip_list: command not found

What did I do wrong here? thanks

Biffen
  • 5,791
  • 5
  • 29
  • 34
BufBills
  • 7,265
  • 9
  • 42
  • 77

1 Answers1

0

as @anubhava suggests, try ${ip_list[@]}, like this:

declare -a ip_list=('10.99.1.1' '10.99.1.2' '10.99.1.3' '10.99.1.4');

for i in ${ip_list[@]} ; do
    ssh -i ~/Downloads/abc.pem -t -t ec2-user@$i "sudo   python /home/user/abc.py"
done
yftse
  • 183
  • 6