I need to get /mysqlsharedetails from all the MySQL servers.
I have written a script using a while read loop, but it's getting the details of only the first server,
#!/bin/ksh
file="/home/mysqladm/server_list/server_list.txt"
# while loop
while IFS= read -r a
do
# display line or do something on $line
output=`ssh $a df -h | grep mysqlshare`
#echo $a,$output
echo $a ,$output >> /home/mysqladm/server_list/output.txt
done < "$file"
I have server_list.txt file in which there are two servers like,
server_name1,
server_name2,
it's going to server_name1 and doing df -h and getting out of script.
Why is the loop not working?
sshand just print the server name? By the way, you should always quote your shell variable references (e.g.,"$a"and"$output") unless you have a good reason not to, and you’re sure you know what you’re doing. Also, just for clarity, you might want to change`…`to$(…)— see this, this, and this. And please indent correctly.cat /home/mysqladm/server_list/ms_mysql_all_servers_list; do share=ssh $server df -h /mysqlshare*$share >>/home/mysqladm/server_list/share.txt done...............this one is working fine but unable to get it using while loop.