Who wants to help me out an AppleScript question

Posted:
in Mac Software edited January 2014
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



Quote:

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

  • Reply 1 of 6
    johnqjohnq Posts: 2,763member
    Show me how you are defining superList?
  • Reply 2 of 6
    toweltowel Posts: 1,479member
    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.
  • Reply 3 of 6
    johnqjohnq Posts: 2,763member
    Quote:

    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.
  • Reply 4 of 6
    nebagakidnebagakid Posts: 2,692member
    {"
  • Reply 5 of 6
    nebagakidnebagakid Posts: 2,692member
    "
  • Reply 6 of 6
    nebagakidnebagakid Posts: 2,692member
    OK, weird things were two posts that I attempted to simply copy and paste the superList into . In text editing field it showed the entire message but as soon as I posted it showed everything up until the first item, which is the airportCode...... does that mean anything?



    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.

    Code:


    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}



Sign In or Register to comment.