Hello Everyone,
I wish I could edit my earlier post, but I can't. The earlier post asks how to make a bash script fill in the password when prompted. I found something that does exactly that: expect.
Expect successfully fills in the password, BUT it breaks something else. Here is the new and improved code, in sync.sh:
-
#!/bin/bash
-
echo -n Password:
-
read -s PW
-
expect -c 'spawn rsync --verbose --stats --progress --compress --times --perms --links --recursive --delete --include-from=incls.txt --exclude "*" /Users/bollweevil/django-site/* awesomewebsite49.com:websites/scripts' -c 'expect password:' -c 'send '$PW'\n' -c 'expect eof'
-
So, let's invoke ./sync.sh
It almost works. "rsync" gets called, it prompts for a password, then "expect" feeds it a password, and the remote server likes the password and accepts it. rsync starts to display its status. And then...
-
building file list ...
-
rsync: link_stat "/Users/bollweevil/django-site/*" failed: No such file or directory (2)
-
0 files to consider
-
What? What's wrong? Let's copy the "rsync ..." line out of the "spawn ..." statement, just a completely direct copy, and then paste it right into the shell:
-
new-host: bollweevil$ rsync --verbose --stats --progress --compress --times --perms --links --recursive --delete --include-from=incls.txt --exclude "*" /Users/bollweevil/django-site/* awesomewebsite49.com:websites/scripts
-
building file list ...
-
45 files to consider
-
What?! Why does it work perfectly now? I copied it exactly! Clearly, "expect" or "spawn" is doing crazy crap and messing things up.
Please help.
Thanks.