Who wants to help me out an AppleScript question
Ohkay, so here is the thing, whenever I run this script, the first time it works, but then if I do it again it fails, saying
the superList is a list of two items, first an airportCode and then a zipCode.
set airportCode to first item of the superList
set zipCode to second item of the superList
set thePath to POSIX path of ((path to application support from user domain as string) & "Sylvester")
set guRL to "http://weather.gov/data/current_obs/" & airportCode & ".xml" as string
set referrerURL to "http://www.host.com/"
set downloadPuppy to ("cd \\"" & thePath & "\\" ; /usr/bin/curl -L -f -# -O \\"" & guRL & "\\" -e \\"" & referrerURL & "\\"")
do shell script downloadPuppy
But, if I specifiy what set airportCode to "KARB", it will work everytime, what can I do?
Quote:
sh: -c: line 1: unexpected EOF while looking for matching `"'
sh: -c: line 2: syntax error: unexpected end of file
sh: -c: line 1: unexpected EOF while looking for matching `"'
sh: -c: line 2: syntax error: unexpected end of file
the superList is a list of two items, first an airportCode and then a zipCode.
Code:
set airportCode to first item of the superList
set zipCode to second item of the superList
set thePath to POSIX path of ((path to application support from user domain as string) & "Sylvester")
set guRL to "http://weather.gov/data/current_obs/" & airportCode & ".xml" as string
set referrerURL to "http://www.host.com/"
set downloadPuppy to ("cd \\"" & thePath & "\\" ; /usr/bin/curl -L -f -# -O \\"" & guRL & "\\" -e \\"" & referrerURL & "\\"")
do shell script downloadPuppy
But, if I specifiy what set airportCode to "KARB", it will work everytime, what can I do?
Comments
Originally posted by Towel
My instinct is that it's a problem with spaces in a path confusing the shell, and the default directories of OSX are riddled with spaces. You have a line with "POSIX path of". Try "quoted form of POSIX path of" instead.
But I assume if his superList is just airport codes, and hardwiring them in works, then it is more likely a list delimiter problem. If it were what you said, it wouldn't work at all.
But I'd need to see more of the code.
I don't think it is the POSIX path thing because the same code has worked for downloading other things, error occurs when I ask it to run the shell script . This is the code that opens up the file where the preferences are saved and converts it to a list.
set this_file to this_file as text
set this_file to open for access file this_file
set myList to (read this_file)
close access this_file
set newAirportCode to first paragraph of myList
set newZipCode to second paragraph of myList
set newcOf to third paragraph of myList
return {newAirportCode, newZipCode, newcOf}