Your best friend for file transfer.

Fetch application logoFetch

AppleScripting SITE CHMOD 755 with filename variable (9 posts)

This is an archived topic. The information in it is likely to be out-of-date and no longer applicable to current versions of Fetch.
  • Started 12 years ago by DougAdams
  • Latest reply 12 years ago from DougAdams
  • DougAdams Member

    Hello Again,

    I've written an AppleScript that will upload text cgi's to my cgi-bin.

    My trouble is that I can't seem to do this:

    send to transfer window 1 ftp command {"SITE CHMOD 755 " my_cgi.cgi}

    ...where my_cgi.cgi contains the name of the file as a string.

    This is from Event Log:

    put into transfer window 1 item alias "Mac OS X:Users:myname:Sites:cgi-local:movefilesfold.cgi" format Automatic without uniquename
    send to transfer window 1 ftp command {"SITE CHMOD 755 movefilesfold.cgi"}
    display dialog "Fetch 4.0.1 got an error: A descriptor type mismatch occurred."

    As you can see, the filename is correct (the statement in the script uses the variable).
    I must be doing something wrong with the syntax, but I'm not sure what.

    I have no trouble setting permissions "by hand"; I got the syntax by recording it as such.

    Your assistance is greatly appreciated, as always.

    Doug

    Posted 12 years ago #

  • Jim Matthews Administrator

    How about:

    send to transfer window 1 ftp command ("SITE CHMOD 755 " & my_cgi.cgi)

    where my_cgi.cgi is a variable holding the name of the CGI. The ampersand (&) tells AppleScript to concatenate the two strings. I've changed the curly braces to parentheses; curly braces indicate a list, which is unnecessary since you're only sending one command.

    Let me know if that does not work,

    Jim Matthews
    Fetch Softworks

    Posted 12 years ago #

  • DougAdams Member

    Hello Jim,

    Well, I got <i>this</i> to work:

    tell application "Fetch 4.0.1"
    set my_file to "my_cgi.cgi"
    send to transfer window 1 ftp command ("SITE CHMOD 755 " & my_file)
    end tell

    Explicitly declaring the my_file variable works.

    However I am using a list garnered from list folder. The strings are, of course, the names of the files in my <i>local</i> cgi-local folder. After determining if the files have been recently updated, those files are sent by Fetch to my server's cgi-local folder and then I do this (within a Fetch tell statement):

    try
    send to transfer window 1 ftp command ("SITE CHMOD 755 " & my_cgi)
    on error errMs from obj1 to newClass partial result PR
    log {errMs, obj1, newClass, PR}
    end try

    Here is the logged error from Event Log:

    (*Fetch 4.0.1 got an error: A descriptor type mismatch occurred., «script», item,*)

    I'm stumped. The same my_cgi variable is used to create the item in the "put into" routine, and files xfer fine.

    Posted 12 years ago #

  • Jim Matthews Administrator

    I wonder if the my_cgi variable is a reference to the local file, in which case you'd want to use (name of my_cgi) rather than just my_cgi.

    Jim Matthews
    Fetch Softworks

    Posted 12 years ago #

  • DougAdams Member

    No, it's from the result of list folder, which returns the names of the files as Unicode text. I've also tried coercing to strings and still no luck.

    Posted 12 years ago #

  • Jim Matthews Administrator

    Fetch 4.0.2 should be able to deal with Unicode strings, so you might try the public beta of 4.0.2 that I expect to release in the next few days.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 12 years ago #

  • DougAdams Member

    Thanks for your kind attention to this dilemma. I will look for the beta!

    Posted 12 years ago #

  • Jim Matthews Administrator

    The beta is now available at:

    http://getfetch4.com/Fetch_4.0.2b1.sit

    Could you give it a try and let me know if the problem is still there?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 12 years ago #

  • DougAdams Member

    Success!

    Works like a charm. This is how I wrote it in the script:

    send to transfer window 1 ftp command ("SITE CHMOD 755 " & a_new_file)

    a_new_file is loaded each repeat loop with the next item from the result of the list folder command -- no coerce necessary.

    Works just as I envisioned -- and as you did, I'm sure. Thanks so much for your help.

    Tomorrow I'm wearing my Fetch Softworks t-shirt to work! :)

    Posted 12 years ago #

Topic closed

This topic has been closed.