User Tools

This is an old revision of the document!


Source

#!/bin/bash
#
# Synchronise deux répertoires en utilisant FTP

HOST="myserver.com"
LOGIN="mylogin"
PASSWORD="mypass"
LOCALDIR="$1"
REMOTEDIR="$2"
EXCLUDED="*.*~"

function Usage()
{
  echo -e "\n  Synchronise un répertoire local avec un répertoire distant en utilisant FTP";  
  echo -e "\n  USAGE: ftpsync local_dir";
  echo;
}

if [ "$LOCALDIR" = "" ]
then
  echo -e "  ERREUR: Veuillez spécifier un répertoire local";
  Usage;
  exit 1;
fi

if [ "$REMOTEDIR" = "" ]
then
  echo -e "  ERREUR: Veuillez spécifier un répertoire distant";
  Usage;
  exit 1;
fi

if [ -e "$LOCALDIR" ]
then
  lftp -c "set ftp:list-options -a;
  open ftp://$LOGIN:$PASSWORD@$HOST; 
  lcd $LOCALDIR;
  cd $REMOTEDIR;
  mirror --reverse \
         --delete \
         --verbose \
         --exclude-glob $EXCLUDED";
fi

check if folder/file exists

#!/bin/bash

wget --tries=1 --spider -S ftp://myserver.com/test 2>&1 | grep "No such file" > /dev/null && echo "not exist" || echo "exist"
wget --tries=1 --spider -S ftp://myserver.com/testa 2>&1 | grep "No such file" > /dev/null && echo "not exist" || echo "exist"

,

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information