Code is working very slow. and output is not as expected, getting only two files in output directory instead of 4. Since i have 4 servers so i should get 4 files. Seems it is creating output file for only first and last server.
Log_report.sh:
#!/bin/bash
MAIN_PATH=/migration/CS_ETL/DM_AUTOMATION
file`enter code here`name='FTP_config.csv'
n=1
while read line; do
IP="`echo $line | awk -F"," '{print $1}'`"
echo $IP
USER_NAME="`echo $line | awk -F"," '{print $2}'`"
PASS_KEY="`echo $line | awk -F"," '{print $3}'`"
SCP_PATH="`echo $line | awk -F"," '{print $4}'`"
CBP_PATH="`echo $line | awk -F"," '{print $5}'`"
CBP_ID="`echo $line | awk -F"," '{print $6}'`"
REMOTE_TOOL_PATH="`echo $line | awk -F"," '{print $7}'`"
MASTER_BACKUP="`echo $line | awk -F"," '{print $8}'`"
./Log_sftp.sh $IP $USER_NAME $PASS_KEY $SCP_PATH $CBP_PATH $CBP_ID $REMOTE_TOOL_PATH $MASTER_BACKUP
n=$((n+1))
mv $MASTER_BACKUP/Exception.log $MASTER_BACKUP/Exception_$CBP_ID.log
done < $MAIN_PATH/TASK/$filename
Log_sftp.sh:
#!/usr/bin/expect -f
set username [lindex $argv 1];
set password [lindex $argv 2];
set ip [lindex $argv 0];
set scp_path [lindex $argv 3];
set cbp_path [lindex $argv 4];
set cbp_id [lindex $argv 5];
set slave_path [lindex $argv 6];
set master_bkp [lindex $argv 7];
spawn sftp $username@$ip:$slave_path/Logs
expect "password: "
send $password\r
expect "$ "
set timeout -1
send "lcd $master_bkp\r"
send "get Exception.log\r"
send "exit\r"
expect "$ "