Files
2026-09-14 12:43:38 +02:00

34 lines
918 B
Bash
Executable File

#!/usr/bin/expect -f
#Copy Crontab of raspberry and serverhost
array set host { 0 "serverhost" 1 "raspberry"}
array set user { 0 "root" 1 "lucas"}
array set port { 0 "3032" 1 "1160"}
for {set i 0} {$i < 2} {incr i 1} {
for {set j 0} {$j < 2} {incr j 1} {
spawn ssh -p $port($i) lucas@$host($i)
expect {
"No route to host" {
puts "spawn ssh -p $port($i) lucas@$host($i) failed."
exit 0
}
"Login Sucsessfull" {
if {$user($j)=="root"} {
send "sudo crontab -l >> crontab.buf\r"
expect "lucas: "
send "Gina\&1994\&Nonna\r"
} else {
send "crontab -l >> crontab.buf\r"
}
#expect "$ "
#send "cat crontab.buf\r"
expect "$ "
send "scp -P 1160 crontab.buf lucas@workhost:~/Documents/Dokumente/Dokumente/Projekte/Server/crontab.$host($i).$user($j)\r"
expect "$ "
send "rm crontab.buf\r"
puts "crontab.$host($i).$user($j) created."
}
}
}
}