|
yostuploadan extremely easy-to-use command-line program
to upload or download files to/from a server
using options stored in a hidden file at the root of the local hierarchy.
You can run yostupload in any directory within your local copy of your web site. It will look recursively toward root until it finds a configuration file (.YostUploadRoot). Now yostupload knows your location within the local hierarchy, knows your upload preferences, and knows how to get to your server, so you don't have to specify a bunch of command arguments to get the job done. yostupload uses rsync or ftp to do the transfers. Also, you can use yostupload -l to ssh directly to the corresponding folder on the server.
Example:
1 Z% cd ~/website/computers 2 Z% yostupload -v mvredir mkredir [ cd '/Users/neddie/website/' ] [ rsync --rsh 'ssh -l neddie' -rRHLtp --bwlimit=3 --partial --progress -v computers/mvredir computers/mkredir DreamHost.com:public_html ] building file list ... done computers/ computers/mkredir/ computers/mkredir/index.html computers/mvredir/ computers/mvredir/index.html sent 24541 bytes received 64 bytes 5467.78 bytes/sec total size is 24287 speedup is 0.99 3 Z% yostupload -lv yostupload: examining current directory [ ssh -t -l neddie DreamHost.com "cd 'public_html'/'computers' && exec $0 -l" ] server 1 Z% pwd /home/neddie/public_html/computers server 2 Z% exit Connection to DreamHost.com closed. 4 Z% yostupload -f /Users/neddie/website/.YostUploadRoot 5 Z%
Usage: yostupload [ -d ] [ -v ] [ -n ] [ -r rootFile ] [ --rsync-args args ] [ path ... ]yostupload -l [ -r rootFile ] [ path ]yostupload -f [ -r rootFile ] [ path ]yostupload -u [ -r rootFile ] [ path ]path defaults to the current directory.
Normally uploads unless
-doption specifies download instead.Or: use the
-loption tosshto the server. The remote shell’s current directory will correspond to path.Or: use the
-foption to output path to rootFile.Or: use the
-uoption to output the URL to path.All path arguments (files and/or folders) must be within a folder hierarchy that serves as a local staging area for a folder on the server.
yostuploaduploads (or downloads) everything in paths between their corresponding locations in the local hierarchy and the server hierarchy.The root of the local hierarchy is identified by the fact that it contains a file called “
.YostUploadRoot”.yostuploadexecutes this file and expects it to output key-value pairs, as in this example:
protocol rsync command /usr/local/bin/rsync host upload.yourhost.com url http://yourhost.com port 12345 user neddie dir public_html rsync-args-up --bwlimit=3 finishUp echo Upload succeeded $(date)Notes on the settings:
protocolcan bersync,ftp, orsftp(default isrsync).commandis optional and defaults to the protocol name.hostis a domain name or IP address with no port appended; or, ifprotocolisrsync,hostmay be omitted for uploading to a folder on the same host.urlis optional; defaults tohttp://$host; used only by the-uoption.portis optional.diris the path on the server; default is your home directory.rsync-args,rsync-args-up, andrsync-args-downare optional; if present, these arguments are passed torsyncfor up/download after the standard upload args-rRHtpor download args-rRHLtp. Don't use--rshhere.finishUpis a command to be run via ssh on host after a successful rsync upload. For example, after uploading crontab, this installs that crontab file on host and reports back the result:
finishUp crontab crontab ; crontab -lUse
rsyncif possible;ftpandsftpcopy with world-readable permissions, and they aren't smart (likersyncis) about transferring only what needs to be transferred. Thersynccommand sets permissions on the server to match those in the local hierarchy, so when the destination is a public web site, local dirs should be searchable by all and local files should be readable by all;yostuploadwarns if some permissions are too restrictive.The
-voption shows thersync,ftp, orsftpcommand actually used and puts the command itself into verbose mode.The
-noption sets-vand refrains from actually running the command.The
-rrootFileoption specifies a different root filename instead of.YostUploadRoot.Unfortunately, older versions of
rsynccan’t download more than one thing at a time, so the script as is won’t try, but the script provides for this if you want to modify the script.
Yostupload works best with rsync, a shell command found on linux, BSD, Mac OS X, etc. For one thing, rsync transfers only things that have changed. For another thing, it uses a secure protocol, yet you can arrange things so you don’t have to enter your password every timethis works without storing the password in a local file. If your web hosting service is doesn’t support rsync for uploads and downloads, you might want to consider switching to DreamHost, which does.
Here’s a sample .YostUploadRoot file:
#!/bin/sh echo host yourhost.com echo user neddie echo dir public_html echo rsync-args-up --bwlimit=3
Here’s where to download
the yostupload program,
which is implemented as a zsh (Z-Shell) script.
|
--rsync-args work rsync only)
.YostUploadRoot file
-l option
-v option
.YostUploadRoot file
-r rootFile, finishUp, and port
-f
-u; fixed bug with remote cd used by -l and finishUp