[X-Unix] two shell scripts for those behind dialup connections

Timothy Luoma lists at tntluoma.com
Thu Aug 25 16:14:13 PDT 2005


I often find that I want to download a large PDF that isn't  
compressed.  (I don't know why they don't at least .zip them)

Since I am behind a slow dialup connection, so it's worth a little  
extra effort to make the download faster.

I wrote two little scripts.  The first one runs on the local  
computer, and executes the second one (gaz) on a server where I have  
a shell account (using ssh)

'gaz' runs wget, retrieves the file, then runs bzip2 on it.

The initial script then runs 'scp' to copy the file from the server  
to the local HD, and then runs bunzip2 and opens the file

So all I do is run the first script (which I called 'sif' [save it  
fast]) like this:

     sif http://www.example.com/pub/docs/whatever.pdf


This works best if you:

     a) have wget installed on the server :-)

     b) have ssh setup to not require passwords, although that's not  
strictly necessary

here is 'sif' followed by 'gaz' (get and zip... although I suppose it  
should have been gab for get and bzip2... whatever happened to bzip1  
btw?  I'm always trying to 'bzip' and 'bunzip' files)



#!/bin/sh

REMOTE_HOST=server.example.com

REMOTE_HOST_PORT=22

REMOTE_DIR=/backups

LOCAL_DIR=$HOME/Downloads/


SHORTNAME=`basename $1`

ssh -p $REMOTE_HOST_PORT $REMOTE_HOST "gaz $@"

scp -P $REMOTE_HOST_PORT $REMOTE_HOST:$REMOTE_DIR/$SHORTNAME.bz2  
$LOCAL_DIR

bunzip2 $LOCAL_DIR/$SHORTNAME.bz2

open $LOCAL_DIR/$SHORTNAME

exit 0
# END OF FIRST FILE (sif)



#!/bin/sh

# this is 'gaz' on 'server.example.com'

SHORTNAME=`basename $1`

# make this the same as $REMOTE_DIR above
SAVE_TO_DIR=/backups

cd $SAVE_TO_DIR && \
wget --no-directories "$*" && \
bzip2 -9v "$SHORTNAME" && \
echo "Done $SHORTNAME.bz2"

exit 0
# END OF SECOND FILE (gaz)




More information about the X-Unix mailing list