ifms-zentyal-scripts/pdc-bulk-add-user-professor.sh
2022-07-25 13:57:48 -04:00

37 lines
613 B
Bash
Executable File

#!/bin/bash
file=$1
# Check if arguments are not empty
if [ -z "$file" ]; then
echo "Usage: $0 <file>"
exit 1
fi
# Check if file exists
if [ ! -f "$file" ]; then
echo "File $file does not exist"
exit 1
fi
# Check if file is empty
if [ ! -s "$file" ]; then
echo "File $file is empty"
exit 1
fi
while IFS="" read -r p || [ -n "$p" ]; do
USERNAME=$(echo $p | cut -d ";" -f 1)
NAME=$(echo $p | cut -d ";" -f 2)
# Check if $USERNAME is empty
if [ -z "$USERNAME" ]; then
echo "Username is empty"
continue
fi
echo "---"
./pdc-add-user-professor.sh $USERNAME "$NAME"
done <$file