Output results of shell script to an array

Below is a portion of code from an Applescript I’m writing. It basically requires a shell script to be embedded in to the Applescript. Currently, the output from the script is saved to a file (>>/Users/Mark/Desktop/output.txt). Is there any way to get the results to go directly in to an Applescript array variable, or reimport the outputted text file in to an array?

Thanks
Mark


do shell script "for ((i=1;i<=31;i+=1)); do
	search=\"<string>\"
	if [ $i -lt 10 ]; then search=\"<string>0\"; fi

	cat /Users/mark/Desktop/tv.xml | grep $search$i\"/\" | tr -d '			<string>' | cut -d \" \" -f 2 | cut -c 1,2,3,4,5 >>/Users/Mark/Desktop/output.txt
	done"

Should be a way, but you better post a sample of the contents of “output.txt”, so we can see what’s going on in such file :wink:

Ok here’s the contents of output.txt. It’s just ASCII text, nothing special.

Mark


15/9/05
16/9/05
16/9/05
17/9/05
17/9/05
21/9/05
22/9/05
22/9/05
23/9/05
23/9/05
28/9/05
21:00
20:30
21:30
19:00
21:10
22:00
20:00
21:00
20:30
21:30
22:00
9
11
11
Sky
ITV1
1
11
11
11
11
1

If you simply need every line in an item-list, just:

set theList to paragraphs of (read ("/Users/Mark/Desktop/output.txt" as posix file))

That’s great jj, thanks very much! :slight_smile:

Why use the output file at all?

set the_ouput to paragraphs of (do shell script "for ((i=1;i<=31;i+=1)); do
	search=\"<string>\"
	if [ $i -lt 10 ]; then search=\"<string>0\"; fi

	cat /Users/mark/Desktop/tv.xml | grep $search$i\"/\" | tr -d '			<string>' | cut -d \" \" -f 2 | cut -c 1,2,3,4,5")

Jon