-
Notifications
You must be signed in to change notification settings - Fork 2
/
load.sh
executable file
·60 lines (49 loc) · 1.51 KB
/
load.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
#!/bin/bash
#
# Virtuoso Bulk Loader Script
#
# Description: Bulk loader script for Virtuoso
# Usage: vload [virtuososo_allowed_directory] [data_file] [graph_uri] [log_file] [virtuoso_password]
# Get input arguments
args=("$@")
if [ $# -ne 5 ]; then
echo "Wrong number of arguments. Correct usage: \"vload [virtuososo_allowed_directory] [data_file] [graph_uri] [log_file] [virtuoso_password]\""
else
VAD=${args[0]}
data_file=${args[1]}
graph_uri=${args[2]}
LOGFILE=${args[3]}
VIRT_PSWD=${args[4]}
# Status message
echo "Loading triples into graph <$graph_uri>..."
# Log into Virtuoso isql env
isql_cmd="isql-v -U dba -P $VIRT_PSWD"
# Build the Virtuoso commands
load_func="ld_dir('$VAD', '$data_file', '$graph_uri');"
run_func="rdf_loader_run();"
select_func="select * from DB.DBA.load_list WHERE ll_file LIKE '%${VAD}%';"
# Run the Virtuoso commands
${isql_cmd} << EOF &> ${LOGFILE}
$load_func
$run_func
$select_func
exit;
EOF
# Write the load commands to the log
echo "----------" >> ${LOGFILE}
echo $load_func >> ${LOGFILE}
echo $run_func >> ${LOGFILE}
echo ${select_func} >> ${LOGFILE}
echo "----------" >> ${LOGFILE}
# Print out the log file
cat ${LOGFILE}
result=$?
if [ $result != 0 ]
then
"Failed to load! Check ${LOGFILE} for details."
exit 1
fi
# Status message
echo "Loading finished! Check ${LOGFILE} for details."
exit 0
fi