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

31 lines
799 B
Bash
Executable File

#!/usr/bin/expect -f
#Copy Crontab of raspberry and serverhost
set host "raspberry"
array set user { 0 "root" 1 "lucas"}
set port "1160"
for {set j 0} {$j < 2} {incr j 1} {
spawn ssh -p $port lucas@$host
expect {
"No route to host" {
puts "spawn ssh -p $port SendEnv=TERM lucas@$host 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 3032 crontab.buf lucas@serverhost:~/Documents/Dokumente/Dokumente/Projekte/Server/crontab.$host.$user($j)\r"
expect "$ "
send "rm crontab.buf\r"
puts "crontab.$host.$user($j) created."
}
}
}