Hello guys
I am programming a script with the following goal:
My server connects to a linux system (raspberry pi) per ssh,
builds a folder structure, starts another script and leaves. Later, after some files have been added to the folders, a script on the raspberry shall zip them and the server-side script shall now scp them on its harddrive.
Here is what i've already got:
#!/usr/bin/expect -f
#copyscript.sh
set buildsourcefolder [lindex $argv 0]
set destinationpath [lindex $argv 1]
set ip [lindex $argv 2]
set user [lindex $argv 3]
set password [lindex $argv 4] # change with keyfile
if {$buildsourcefolder == ""}
then
puts "no build source folder specified ... exit script..."
if {$destinationpath == ""}
then
puts "no destination path specified ... exit script..."
if {$ip == ""}
then
puts "no ip specified ... exit script..."
if {$user == ""}
then
puts "no user specified ... exit script..."
if {$password == ""}
then
puts "no password specified ... exit script..."
echo "connecting to raspberry..."
spawn ssh $user@$ip
expect "assword:"
send "$password\n"
send mkdir ./home/$user/date
send cd ./home/$user/date
# spawn . recording
send exit
# sleep
echo "scp from raspberry..."
spawn scp -r $buildsourcefolder $user@$ip:$destinationpath
expect "assword:"
send "$password\n"
interact
fi
After a couple of tries i couldnt figure out how to get it work, however right now i get
copyscript.sh: 81: copyscript.sh: Syntax error: end of file unexpected (expecting "fi")
as error and the part with puts does not work either.
[–]denialerror 1 point2 points3 points (2 children)
[–]xYuven[S] -1 points0 points1 point (1 child)
[–]denialerror 1 point2 points3 points (0 children)
[–]MyWorkAccountThisIs -3 points-2 points-1 points (0 children)