Last active
January 17, 2019 10:09
-
-
Save r4ulcl/cb0eff427d6585192b8faedb42781ee1 to your computer and use it in GitHub Desktop.
Script en bash utilizando transmission para obtener IPs descargando un fichero torrent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#author : Raul Calvo Laorden (raulcalvolaorden@gmail.com) | |
#description : Script en bash utilizando transmission para obtener IPs descargando un fichero torrent | |
#date : 2018-04-30 | |
#usage : bash torrentScript.sh [options] | |
#----------------------------------------------------------------------------------------------------------- | |
trap ctrl_c INT | |
function ctrl_c() { | |
echo -e "\nCTRL-C. Closing..." | |
transmission-remote -t $ID -rad > /dev/null 2>&1 # borramos el fichero | |
transmission-remote --exit > /dev/null 2>&1 #Cerramos transmission | |
echo "done." | |
exit | |
} | |
if [ -z "$1" ] | |
then | |
echo "No argument supplied" | |
echo "Usage: $0 <file.torrent>" | |
exit | |
fi | |
transmission-remote --exit > /dev/null 2>&1 #Cerramos transmission | |
sleep 2 | |
transmission-daemon #iniciamos transmission | |
sleep 2 | |
#start daemon | |
transmission-remote -a $1 > /dev/null 2>&1 | |
#get id | |
ID=$(transmission-remote -l | tail -2 | head -1 | awk '{print $1}') | |
CONTADOR=0 | |
while true | |
do | |
#create peersUniq.txt | |
touch peersUniq.txt | |
#get peers | |
transmission-remote -t $ID -ip | grep -v "Address" >> peers.txt | |
#save uniq ip and client | |
cat peersUniq.txt peers.txt | awk '{print $1 "," $6$7$8$9}' | sort | uniq > peersUniq.txt | |
#sleep 10 secs | |
sleep 10 | |
CONTADOR=$((CONTADOR+1)) | |
#cada minuto | |
if (( $CONTADOR % 6 == 0 )) ; then | |
date | |
cat peersUniq.txt | wc -l | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explicación*