Paste #139269 |
pasted on 28.07.2020 14:00
- Edit to this paste
- Raw
- The following pastes replied to this paste: # 223137 # 236535 # 245668
- Show paste tree
-
Compare with paste
#
Text paste
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #! /bin/bash if [[ "$1" == "help" ]] then echo "Utilisation sftp-send.sh USER PASS HOST FICHIER" exit 0 fi if [[ $# -ne 4 ]] then echo "Toutes les options n'ont pas été passées correctement" exit 40 fi SFUSER=$1 SFPASS=$2 SFHOST=$3 SFFILE=$4 if [[ $(ping -c 1 -W 1 $SFHOST | grep -c "time=") -eq 0 ]] then echo "Le serveur $SFHOST ne répond pas" exit 41 fi if [[ -f $SFFILE ]] then sshpass -p $SFPASS sftp $SFUSER@$SFHOST << FINSFTP cd data put $SFFILE exit FINSFTP else echo "Le fichier $SFFILE n'existe pas" fi |