Shell script using expect to login to couple of remote servers and read "crontab -l"
I need a shell script using expect to login to couple of remote servers and read "crontab -l -u <username>" & "cat /etc/rc.local" & "df -h" and able to create output into a file saved locally with hostname.crontab & hostname.rc.local & disk.status. I can supply a file as list of hostname or IP address. it should also create a summary at the end with the status if any server unable to login with error.
Please help. |
Quote:
Otherwise, you can easily find THOUSANDS of bash scripting tutorials on Google...there's even one in my post signature. Read/follow them. |
I tried writing the script & outputs as file hostname.crontab & hostname.rc.local & disk.status and summary of success and failure. I provided a input as list of hostname from a file.
for i in `cat hostname` do expect -c " spawn ssh -t username@$i \"cat /etc/rc.local\" >> $i.rc.local spawn ssh -t username@$i \"crontab -l -u root\" >> $i.crontab spawn ssh -t username@$i \"df -h\" >> $i.disk.status expect { -re \".*Are.*.*yes.*no.*\" { send \"yes\n\" exp_continue } } expect { "?assword:" { send -- \"password\r\"; interact } } " done if someone can help me fine tuning. |
Quote:
|
All times are GMT -5. The time now is 08:12 AM. |