Posted on 02-24-2016 05:44 PM
So we have a mac that was stolen. We have Undercover installed and hope to see it pop up soon but I would like to be able to recover the /Users/username/Desktop/ and /Users/username/Pictures/ folders if I can. She is quite bother by her children's photos being out there.
I have the start of a script but I am having both an issue with expect and spawn at this point.
#!/usr/bin/expect
spawn scp -r /Users/username/Desktop/ root@remoteserver:/remote/path/to/upload
expect "(yes/no)?" {send "yes
”}
expect "Password:" {send "secretpassword
”}
spawn scp -r /Users/username/Pictures/ root@remoteserver:/remote/path/to/upload
interact
spawn throws an error about not being a command and my expect command does not seem to work.
Posted on 02-25-2016 12:53 PM
If she is just bothered by the photos being out there wouldn't it be faster and easier to just delete both directories as soon as it connects?
Posted on 02-25-2016 12:57 PM
She had not been running Time Machine as directed
Posted on 02-25-2016 01:11 PM
I hope you're getting something good out of this. Here's a similar script I've written, which worked to remotely upload a zip of files on users' machines.
#!/bin/sh
## Get User Name.
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
## Add all of the folders in the list to a zip.
zip -r /tmp/$loggedInUser.zip /Users/$loggedInUser/Documents/CollectionFolder/*
## sFTP to secure location
HOST='HostHere'
USERNAME='sftpusr'
PASSWD='PWHere'
PORT=22
FILE=/tmp/$loggedInUser.zip
/usr/bin/expect<<EOD
spawn /usr/bin/sftp -o Port=$PORT $USERNAME@$HOST
expect "Are you sure you want to continue connecting (yes/no)?"
send "yes
"
expect "Password:"
send "$PASSWD
"
expect "sftp>"
send "cd '/volumes/Data 1/Transfer'
"
expect "sftp>"
send "put $FILE
"
expect "sftp>"
send "bye
"
EOD
Posted on 02-25-2016 01:59 PM
Ill give that a try that looks like exactly what I need. Thanks!
Posted on 02-25-2016 02:01 PM
so can the list go as such?
## Add all of the folders in the list to a zip.
zip -r /tmp/$loggedInUser.zip /Users/$loggedInUser/Desktop/* /Users/$loggedInUser/Pictures/*
Posted on 02-26-2016 08:46 AM
Yup