0

I have a script I am working on that reads off of a text file and will use the information stored in the text file to put each line entered in as an array. This array is a reference to files that are imported to a directory in another script. The problem is I built a function to zip the contents of the directory and change it's ownerships, but when I run the script it was zipping and attempting to change ownerships of the pwd. Here is my code below:

file=~/exporttool/zipFiles.txt
index=0
declare -a studyinstanceuids
while read line ; do
        studyinstanceuids[$index]="$line"
        index=$((index+1))
        echo $line
done < $file
for i in "${studyinstanceuids[@]}"
do
echo "$i" | ./cmd2;
done
echo "Exams are in!";

##Function with argument that will take prompt to change ownerships
echo "What is the name of the owner: "
read $owner

zipForOwner(){
        arg1=$1
        for i in "${studyinstanceuids[@]}"; do
                zip -r ~/export/"${studyinstanceuids[@]}"/20140620_"${studyinstanceuids[@]}".zip .
                sudo chown $1:$1 ~/export/"${studyinstanceuids[@]}"/"${studyinstanceuids[@]}".zip
                sudo mv ~/export/"${studyinstanceuids[@]}"/"${studyinstanceuids[@]}".zip ~/home/"$1"
        done
}

zipForOwner $owner
exit;

Does anyone have any suggestions?

1

Found the problem. The problem is with the zip -r ~/export/"${studyinstanceuids[@]}"/20140620_"${studyinstanceuids[@]}".zip .

I need to change it to zip -r ~/export/"${studyinstanceuids[@]}"/20140620_"${studyinstanceuids[@]}".zip ~/export/"${studyinstanceuids[@}"/

The . at the end was causing the problem.

  • I cant yet, it says I can only do it after two days. – ryekayo Jun 20 '14 at 17:57
  • oh ok, well then :( – polym Jun 20 '14 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.