Last active
October 1, 2015 01:28
-
-
Save cmavr8/1894226 to your computer and use it in GitHub Desktop.
Examine OCS (Open Conference Systems) users
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 | |
# Little script to examine a PKP OCS user database. Instructions: | |
# 1. Login to OCS and export the users as an xml | |
# 2. Convert the file to CSV using e.g. Stylus studio 2011 XML Enterprise Suite | |
# 3. Change this line: | |
INPUT=users.csv | |
# 4. Run the script | |
OLDIFS=$IFS | |
IFS=, | |
all=`wc -l users.csv | cut --delimiter\=" " -f 1` | |
# Counters for various universities: | |
auth=0 | |
emp=0 | |
duth=0 | |
upatras=0 | |
uowm=0 | |
others=0 | |
# Open the file | |
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } | |
# Parse each line | |
while read usr sn fname lname affil email what what2 sex locale | |
do | |
<<COMMENT1 | |
echo "Username : $usr" | |
echo "Serial Number : $sn" | |
echo "First Name : $fname" | |
echo "Last Name : $lname" | |
echo "Affiliation : $affil" | |
echo "Email : $email" | |
echo "What : $what" | |
echo "What2 : $what2" | |
echo "Sex : $sex" | |
echo "Locale : $locale" | |
COMMENT1 | |
# Now try to match a university title to each entry's "affiliation" field | |
if [[ "$affil" == *απθ* || "$affil" == *ΑΠΘ* || "$affil" == *Αριστο* || "$affil" == *ΑΡΙΣΤΟ* || "$affil" == *AUTH* || "$affil" == *A.U.T* || "$affil" == *Α.Π.Θ* || "$affil" == *Aristo* ]]; then | |
let auth=auth+1 | |
elif [[ "$affil" == *εμπ* || "$affil" == *ΕΜΠ* || "$affil" == *Μετσ* || "$affil" == *ΜΕΤΣ* || "$affil" == *EMP* || "$affil" == *Ε.Μ.Π* || "$affil" == *National* || "$affil" == *NTUA* ]]; then | |
let emp=emp+1 | |
elif [[ "$affil" == *δπθ* || "$affil" == *DUTH* || "$affil" == *duth* || "$affil" == *dpth* || "$affil" == *Δημοκρ* || "$affil" == *ΔΗΜΟΚΡ* || "$affil" == *δημο* || "$affil" == *ΔΠΘ* || "$affil" == *Δ.Π.Θ* || "$affil" == *demo* || "$affil" == *Demo* ]]; then | |
let duth=duth+1 | |
elif [[ "$affil" == *Πατρ* || "$affil" == *ΠΑΤΡ* || "$affil" == *πατρ* || "$affil" == *Πάτρ* || "$affil" == *πάτρ* ]]; then | |
let upatras=upatras+1 | |
elif [[ "$affil" == *Δυτ* || "$affil" == *ΔΥΤ* || "$affil" == *Κοζ* || "$affil" == *ΚΟΖ* ]]; then | |
let uowm=uowm+1 | |
else # Print everything that didn't fit | |
echo "*** UNCATEGORIZED:" | |
echo $affil | |
fi | |
done < $INPUT | |
IFS=$OLDIFS | |
echo "" | |
echo "*** Results:" | |
echo "Total Registered: $all" | |
echo Thessaloniki: $auth | |
echo EMP: $emp | |
echo DUTH: $duth | |
echo Patra: $upatras | |
echo Kozani: $uowm | |
let others=all-auth-emp-duth-upatras-uowm | |
echo Other Universities or invalid data: $others |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment