Hi Friends,
Please forgive me if i am asking basic questions due low knowledge in scripting.
here the code i am using for populating database
#!/bin/bash
#ip=$2
tar_file=$1
bkp_name="bkp-$$"
if [ -z "${tar_file}" ]; then
echo "Usage import.sh [tar file]"
exit 1
fi
for keyspace
do
keyspace=$(basename "${tar_file}" ".tar.gz")
mkdir -p "${bkp_name}"
tar -xvzf "${tar_file}" -C "${bkp_name}"
echo "Drop keyspace ${keyspace}"
cqlsh -e "drop keyspace \"${keyspace}\";"
echo "Create empty keyspace: ${keyspace}"
cat "${bkp_name}/${keyspace}.sql" | cqlsh localhost
for dir in "${bkp_name}/${keyspace}/"*; do
sstableloader -d localhost "${dir}"
done
done
I run this program like
sh import.sh abc.tar.gz 123.tar.gz xyz.tar.gz
What happening is it working but its keep looping , after doing with abc, 123, xyz and again it starting from abc...and so on..
Can you please correct where i am doing wrong
Thanks
------ Post updated at 11:16 AM ------
oh my bad,
I need to loop through tar_file not the keyspace
for tar_file should be there instead of for keyspace
trying it now
------ Post updated at 11:28 AM ------
I have solved my self...