eswues
eswues

Reputation: 129

bash read does not wait for input

I have this code:

#!/bin/bash
for some_host in $(cat some_list); do
    echo $some_host
    ssh $some_host sudo cat /etc/some.conf |grep -i something_to_grep
    printf "\nPut the input: " read some_input
    echo $some_input
    
done

When I run it, it just continues without waiting for my input. I need to copy/past something form ssh output for further action :/

Upvotes: 1

Views: 4221

Answers (1)

Shammel Lee
Shammel Lee

Reputation: 4475

Change

printf "\nPut the input: " read some_input

to

read -p "Put the input: " some_input

Example

for host in '1.1.1.100' '1.1.1.101' '1.1.1.102'
do
    read -p "Enter your input for ${host} " host_input
    echo "${host} says ${host_input}"
done

Upvotes: 3

Related Questions