-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathAWSIoTArduinoYunScp.sh
executable file
·36 lines (32 loc) · 1.08 KB
/
AWSIoTArduinoYunScp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/expect
# This script helps to upload the targeted file/directory to remote Arduino Yun Board
# Args check
if {$argc!= 5} {
send_user "usage: ./AWSIoTArduinoYunScp.sh <Board IP> <UserName> <Board Password> <File> <Destination>\n"
exit
}
set timeout 10
set ArduinoYunIPAddress [lindex $argv 0]
set ArduinoYunUserName [lindex $argv 1]
set ArduinoYunPassword [lindex $argv 2]
set TargetFile [lindex $argv 3]
set Destination [lindex $argv 4]
set RemoteEndpoint "$ArduinoYunUserName@$ArduinoYunIPAddress:$Destination"
send_user "Arduino Yun IP is: $ArduinoYunIPAddress\n"
send_user "Arduino Yun User Name is: $ArduinoYunUserName\n"
send_user "\nNow start transmitting $TargetFile to remote directory: $RemoteEndpoint ...\n"
# scp automatically creates the missing directory
spawn scp -r $TargetFile $RemoteEndpoint
expect {
# In case this is the first time
-re ".*yes/no.*" {
send "yes\r"; exp_continue
-re ".*assword.*" { send "$ArduinoYunPassword\r" }
}
-re ".*assword.*" { send "$ArduinoYunPassword\r" }
}
expect {
eof {
send_user "Completed!\n"
}
}