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 Answer 1

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.

2
  • I cant yet, it says I can only do it after two days. Commented Jun 20, 2014 at 17:57
  • oh ok, well then :( Commented Jun 20, 2014 at 17:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.