Hi
I have a textfile with servers that is being read by a backup script in a while loop. Here is it, simplified a bit:
servers.txt:
Quote:
server1 database1
server2 database2
|
and so on...
This works fine:
Code:
cat servers.txt |
while read line
do
server=$(echo $line |awk '{print $1}')
database=$(echo $line |awk '{print $2}')
echo "Server: $server - Database: $database"
done
Then I add code that actually do something:
Code:
cat servers.txt |
while read line
do
server=$(echo $line |awk '{print $1}')
database=$(echo $line |awk '{print $2}')
echo "Server: $server - Database: $database"
ssh $server "mysqldump -u root --password=mysecret $database" >$database.sql
echo "Ok"
done
The problem is, when I add the ssh command, the script stops after the first line. The database dump is made, "Ok" is printed, but the loop stops. Somehow the ssh command messes up the reading of the textfile it seems.
Is there perhaps a different way to read thru a textfile, without using pipes?