#!/bin/bash

if [ $# -lt 1 ]; then
  echo "Forgot password"
  exit
fi;

pass=$1

cd $HOME/projects/

echo "cd htdocs/nightly/
put qdvdauthor.tar.bz2
quit
"

if [ -f qdvdauthor.tar.bz2 ]
then
  rm qdvdauthor.tar.bz2
fi

allFiles=`find qdvdauthor -type f | grep -v CVS`
tar -cjf qdvdauthor.tar.bz2 $allFiles

echo
ls -ll qdvdauthor.tar.bz2
echo

#sftp qdvdauthor,qdvdauthor@web.sourceforge.net

expect -c "
set timeout 1000;
spawn sftp qdvdauthor,qdvdauthor@web.sourceforge.net
expect \"password:\" 
send   \"$pass\r\"

expect \"sftp>\"
send   \"cd htdocs/nightly/\r\"

expect \"sftp>\"
send   \"put qdvdauthor.tar.bz2\r\"

expect \"sftp>\"
send   \"quit\r\"
"

echo


