home   |   contact
   
profile services projects tutorials
 
     
  home :: projects :: file transfer script       
 

Recent Projects

snapbomb
flexfwd
adrenalin
realworld
insite

General Programming

december project
threaded web server
recursive desent parser
kernel mod

Graphics Programming

introduction
subdivision
loop subdivision+
md2 file animator
key frame animator
collision detection
collision detection 2
cloth simulation
bsp tree/game
water simulation
radiosity

Shell Scripts

backup script
file transfer


   print this page
  email this page
> login

 file transfer shell script

Name: Backup Shell Script
Language: /bin/bash
API: OpenGL
Platform: Linux/Solaris

functions.sh

    #!/bin/bash
#
# utility functions
#
# - gets included in other scripts
# as it is a list of kewl functions
# - they should go in $HOME/bin to be
# found by some of the other scripts
# that I have writen #
# Version 1.0 - Corey Auger
# corey@coreyauger.com
#

# set the path like a good little monkey
PATH=/bin:/usr/bin:/sbin:/usr/sbin

#===========================================================
sf_sendFiles() # function to send files to a host and port
#===========================================================
# arg1 HOST = The name of the listening host to send to
# arg2 PORT = The port number to try to send data on
# {arg3, arg4 ..} FILES = all the files to send to the host
{
   if [ $# -lt 2 ]; then # wrong number of arguments ?
      # print an error and return an error status
      echo "Usage: host port {files}"
      return 1
   fi
   SF_HOST=$1; shift # host argument ( in theory )
   SF_PORT=$1; shift # port argument ( in theory )

   # all other arguments are files
   SF_FILES=$@
# this is the actual file transfer line... we first tar all the
# files and then pipe it into a writing netcat connection
   tar cpz $SF_FILES | nc -w 1 $SF_HOST $SF_PORT
   return $? # return the error code
}
#===========================================================


#=============================================================
sf_recieveFiles()
#=============================================================
# arg1 PORT = The port that we want to bind a listening conn
# arg2 FILE = The tar file that we want to name all the files
{
   if ! [ $# -eq 1 ]; then # check the # of args
      # print error and exit with return code
      echo "Usage: port"
      return 1
   fi
# tell netcat to listen on the PORT for 50 seconds in the
# background and to write its info to the file name given
# by the second argument
   nc -vlp $1 | tar xzvp
   return $? # return the error code
}
#=============================================================


filetransfer.sh

   
#!/bin/bash
#
# filetransfer - sweet file transfer program
#
# - used as a server and client
# - Client: tar there files and send it
# it down the pipe to the server on the
# port of your choice.
# - Server: listen for connections on a
# port ... decompress the tar file when
# it is recieved.
#
# Version 1.0 - Corey Auger
# corey@coreyauger.com
#

# set the path like a good little monkey
PATH=/bin:/usr/bin:/sbin:/usr/sbin

. $HOME/bin/functions # import my kewl functions


if [ $# -lt 2 ]; then # wrong number of arguments ?
# print an error and return an error status
   echo "Usage recieve file: $0 r (port)"
   echo "Usage send files: $0 s (host) (port) {files}"
   exit 1
fi


if [ $1 == 'r' ]; then # check if server mode
   shift # get rest of arguments
   sf_recieveFiles $@ # send them to function
elif [ $1 == 's' ]; then # check if client mode
   shift # get rest of arguments
   echo "$@"
   sf_sendFiles $@ # send arguments to function
else # first arg was wrong
   echo "Usage recieve file: $0 r (port)"
   echo "Usage send files: $0 s (host) (port) {files}"
   exit 1
fi

if ! [ $? ]; then
   echo "Error occurd, in send or recieve"
   exit $?
fi

exit 0 # exit




FlexFWD

FlexFWD is a social fitness logging tool. Connect with friends and follow athletes. Log: crossfit, running, swimming, or cycling. With mobile applications for the iPhone and Android devices, FlexFWD also integrates with your Nike+ and Garmin devices. This is the Utimate site for tracking and comparing your fitness restults to your friends and family. Click here to visit the project.



december project

The december project is a distributed internet backup project that I have been working on. This project is a distubuted cloud style backup system with error correction codes built in.


one2one

One2one is an opensource project that I started at source forge. One2one is a database transformation tool. The tool allows for easy transformation of data from one source to another. Take general data descriptions and map them into complex table hierarchies of any major database vendors. Click here to goto sourceforge and download the project code.

 
  Copyright © corey auger 2004