-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathipctrl_importer.sh
More file actions
executable file
·40 lines (32 loc) · 1.03 KB
/
ipctrl_importer.sh
File metadata and controls
executable file
·40 lines (32 loc) · 1.03 KB
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
#!/bin/bash
# Check if two arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <bash_script> <csv_file>"
exit 1
fi
# Start timer
SECONDS=0
# Assign arguments to variables
bash_script=$1 # IPControl CLI command
csv_file=$2 # IPControl import CSV
# Username and password variables
username="incadmin" # IPControl database user
password="incadmin" # IPControl database user password
# Check if both files exist
if [ -f "$bash_script" ] && [ -f "$csv_file" ]; then
# Extract filename without extension
filename=$(basename -- "$csv_file")
extension="${filename##*.}"
filename="${filename%.*}"
# Create reject and error file names
reject_file="${filename}_reject.${extension}"
error_file="${filename}_error.${extension}"
# Run the command
./"$bash_script" -u "$username" -p "$password" -f "$csv_file" -r "$reject_file" -e "$error_file"
else
echo "Both files must exist."
exit 1
fi
# Stop timer
duration=$SECONDS
echo "process took $(($duration / 60)) minutes and $(($duration % 60)) seconds"