corz.org text viewer..
[currently viewing: /public/scripts/osx-terminal/shell scripts/auto-ftp.sh - raw]
#!/bin/sh

# generic automatic ftp script

# ftp'ing manually is bad news. for a start, that gap between deleting
# and replacing a file can cost you a visitor.. 404. secondly, it takes
# too bloody long. this "just happens", and is 100%. can't go back to
# manual site updating now.

# drop this somewhere in your PATH (like /usr/local/bin), rename to
# something cute, and chmod +x

# © corz.org 2004-> - edit freely..

# NOTE: This is DEPRECATED! Take a look here..
#
#    http://corz.org/machine/source/php/website-sync-mac.php
#    http://corz.org/machine/source/php/website-sync-linux.php
#
# ;o)
#

HOST="ftp.myhost.org"
USER="MyUsername"
PASSWD="MyPassword"

ftp -n $HOST <<FTP_COMMANDS
quote USER $USER
quote PASS $PASSWD
binary

put "/Volumes/cor/somefile.php" "/var/www/html/somefile.php" 
chmod 777 "/var/www/html/somefile.php"

FTP_COMMANDS
exit 0

#    the script has exited already, we can use this space for comments..
#    you can delete all this lot once you digest it.

#    all the stuff you'd normally do with ftp is okay in a script.
#    you can set binary or ascii mode for each file, too. as above.
#    check out the ftp manpage for ideas. a few more examples..

#    get a file..
get "/var/www/html/inc/db/email_list.txt" "/Users/cor/desktop/new_email_list.txt"

#    delete a file..
delete "/var/www/html/blog/arc/blogz_up.bak"

#    move a file somewhere..
quote rnfr $USER "/var/www/html/blog/blogz.blog"
quote rnto $USER "/var/www/html/blog/arc/blogz_up.bak"

#    upload and make writeable..
put "/Volumes/mac/webserv/cor/blog/blogz.blog" "/var/www/html/blog/blogz.blog"
chmod 777  "/var/www/html/blog/blogz.blog"

# note: don't put comments inside the ftp commands section, just real commands.

Welcome to corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!