-
Notifications
You must be signed in to change notification settings - Fork 2
/
torrentScanner.sh
executable file
·91 lines (66 loc) · 1.96 KB
/
torrentScanner.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Script to scan for .torrent files and reports the found results to google forms
#google form
#see https://eureka.ykyuen.info/2014/07/30/submit-google-forms-by-curl-command/ to set these values
formID="google_DocumentID"
field1="entry.fieldID"
field2="entry.fieldID2"
field3="entry.fieldID3"
field4="entry.fieldID4"
#create a google form
#add two text fields
#disable requiring sign in
#create a result form
#in select A B C columns, create a pivet table
#in pivot table add rows column B, add rows column C
#in pivot table add values column B, add rows column C
# Stop IFS linesplitting on spaces
OIFS=$IFS
IFS=$'\n'
#get computer name
computerName=$(hostname)
#print computer name
echo ""
echo "Computer: ${computerName}"
echo ""
# print notice start spotlight search
echo ""
echo "Searching Started"
# spotlight search as root for .torrent files
paths=($( mdfind -name .torrent ))
# print notice end of spotlight search
echo "Searching Completed"
echo ""
# print start of processing
echo ""
echo "Processing Results Started"
# Process located files
# check for results
if [ ${#paths[@]} != "0" ];
then
for (( loop=0; loop<${#paths[@]}; loop++ ))
do
# set path
aPath[$loop]=$( ${paths[$loop]} )
#print path
echo "Path: ${aPath[$loop]}"
# set filename
fileName[$loop]=$( basename ${paths[$loop]} )
#print fileName
echo "FileName: ${fileName[$loop]}"
#st ownerOfFile
ownerOfFile[$loop]=$( ls -l ${paths[$loop]} | awk '{print $3}' )
#print ownerOfFile
echo "Path: ${ownerOfFile[$loop]}"
curl --silent https://docs.google.com/forms/d/$formID/formResponse -d ifq --data-urlencode $field1="${computerName}" --data-urlencode $field2="${ownerOfFile[$loop]}" --data-urlencode $field3="${fileName[$loop]}" --data-urlencode $field4="${aPath[$loop]}" -d submit=Submit > /dev/null
done
fi
# add line break
echo ""
# print end of processing
echo ""
echo "Processing Results Completed"
# Start IFS linesplitting on spaces
IFS=$OIFS
#exit
exit