Your best friend for file transfer.

Fetch application logoFetch

Applescripting Command Line (17 posts)

  • Started 3 years ago by Hoons724
  • Latest reply 3 years ago from Scott McGuire
  • Hoons724 Member

    I'm using Applescript to upload massive quantities of files for my company (one at a time, not in batch) and each file requires a command-line. I see in the Applescript dictionary where I can send command lines with the files, but I can't seem to get the syntax right. Can anyone show me an example of the syntax for this?

    Right I'm using Fetch 5.6 on Mac OS X 10.4.2

    My upload line looks like this:

    put into url theURL item theFile

    I would like to know how the line for sending the command line would look and would I place it before or after the 'put into' line?

    Thanks in advance for your help!

    Hoons

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi,

    In order for us to best help you, could you please tell us more about what you mean when you say "each file requires a command line?" What do you need to do to each file after it is uploaded?

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    I'm sending to a single URL for every file. The admin sent out a 'how to' stating how our command lines should read, which was something like this:

    put filename.eps %ABCD-TEST%EPS%12345678901234

    ABCD = company initials
    12345678901234 = unique industry code of file

    I explained to him I was using Fetch to send these and do not know how to send a command line with the file (or use one to send a file). So I found in the Fetch dictionary that you can send command lines. Since I typed this original message, I've got the syntax down to where it sends the line.

    After my put into statement for the file, I have:
    send to transfer window 1 ftp command theCommand

    theCommand = "put filename.eps %ABCD-TEST%EPS%12345678901234" with appropriate variables in place

    The FTP site is returning: 500 command not understood.

    So this may no longer be a Fetch/Applescript issue anymore, but something for the FTP admin. He told me to turn off binary and to send the file in format BinHex, which I did. I got the same 500 error

    Can you tell me from what you see if I'm doing anything wrong or is this strictly an site admin issue. He knows very little about Fetch and nothing about Applescript.

    Thanks for responding

    Posted 3 years ago #

  • Hoons724 Member

    One more thing: He is telling me not to use passive mode. I 'unchecked' it in the Preferences and in the script I added the line "set use passive mode to false" and it's still sending in passive mode. Is there somewhere else I need to turn this off? Thanks again

    Hoons

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi,

    So, if I understand correctly, what you need to do is upload each file so that it has a different name on the server than on your Mac, is that correct? That is what you're trying to accomplish?

    Just as a test, have you tried uploading one of the files using the Fetch interface instead of AppleScript, just to make sure that basic uploading works?

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    Uploading seems to work fine. I'm not changing filenames. I'm just trying to place the files on their FTP site as I have them on my Mac. We use Fetch and Applescript all the time to send files to various industry partners, but this one for some reason insists we send with a command line. I believe its necessary for something they're doing on their end. I just don't understand command lines enough to know what they're for and how they are presented.

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi,

    I have consulted with my colleagues about your question.

    The problem is you cannot send "put file.txt" commands through Fetch - for technical reasons, that will not work. You are pretty much guaranteed to get an error from the server regardless of what you do. There are some command-line commands you can send through Fetch, but "put" is not one of them.

    So, the question is, how to accomplish what the admin is asking you to do without sending a command.

    The FTP command put's syntax is:

    put name-of-local-file-to-upload name-to-give-file-on-server

    So, it looks like the admin really is asking you to rename the files as you upload them, using the name format he's specified (%ABCD-TEST%EPS%12345678901234). You may want to confirm with the admin that is what he's really looking for, but based on the information you've given us, that is what it looks like he's asking you.

    If the files don't have those names already, you'll need to use AppleScript to first tell the Finder to rename the file, and then tell Fetch to upload the renamed file. (When you're using AppleScript, Fetch cannot rename a file when uploading.) I believe that will accomplish what the admin wants you to do. If the files are already named in the way he wants, then you should just upload them, as normal.

    And I wouldn't worry about the "don't use passive" instructions too much - if the upload succeeds, then using passive didn't hurt anything. The reason you see Fetch trying it is because passive modes are more reliable if the server supports them; if the server doesn't, Fetch should switch back to not using passive.

    I hope this helps point you in the right direction. Please let us know if you have more questions.

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    Looks like what you suggested above has put me in the right direction. Renaming the file to the naming convention from above (%ABCD-TEST%EPS%12345678901234) seemed to work. Apparently the filenames are three-field records with the perc marks being the delimiters. The second field is the file format, the third is the ID#. After seeing the successful upload on the transcript, I saw it had listed this data in columns. The problem I ran into is that the script automatically appended the .zip extension to the filename making the ID# value 12345678901234.zip rather than 12345678901234

    My local file does not have the .zip extension on it and I double-checked the 'get info' dialog to make certain it wasn't there and just hidden. Can I procedurally tell Fetch to leave the .zip extension off of the transmitted filename? I can't find where to assign the name in the script. Right now I'm having Finder change the name before Fetch send it.

    For now, I put another delimiter after the ID and that seems to work, but now I'm breaking the naming convention.

    Thanks again for all your help.

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi,

    I'm glad that helped get you pointed in the correct direction.

    I'm a little unclear where or why the .zip extension is getting added; once I understand where it's coming from I can try to advise. Is the original file a .zip file, and it just doesn't have a .zip extension? Is your script zipping it before uploading? Or is Fetch zipping the file when you upload it?

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    My script has Finder taking three corresponding files (EPS, PDF and TXT) from two local locations and putting them in one local location. Then Finder renames them to a specific (pre-archive) convention. The script then has DropStuff zip them as they are named*. Finder then renames them again to the (post-archive) convention mentioned above leaving off the .zip extension. (It is here that I verify '.zip' does not exist in the filename). Fetch then transmits the 3 Zip files to a single remote location. It is here where the '.zip' is appearing on the filenames in the remote file list.

    * - Originally, I had DropStuff renaming the files as it Zipped them, but this caused DropStuff to crash so I changed it to have it Zip the files as they were named and then Finder rename them.

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi,

    Thanks for the information. No, Fetch cannot rename files as it uploads them, so I think your current solution of having the Finder change the name before uploading is the best option.

    If I've misunderstood, please let me know.

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    At this point I'm only looking for a way to prevent Fetch from automatically added the .zip extension.

    In the script I tell it to send zip file 123456 and it sends the file as 123456.zip

    I can't seem to prevent the .zip from appending during the transmission. I think once I do that, I will be good.

    Darren

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi Darren,

    Sorry, I guess I did misunderstand. Fetch should not be adding a .zip extension unless Fetch itself is doing the zipping of the file, but you say that you are using DropStuff to zip it first.

    So if I understand, this is what is happening:

    * You use DropStuff to turn 3 files (eps, pdf, txt) into 3 individual zipped files. You are not combining the 3 files into a single zip file.
    * You rename the 3 files to the new naming convention, which does not include .zip as part of the name.
    * You ask Fetch to upload the 3 files, and a .zip extension gets added.

    Is that correct?

    When you upload the 3 files with Fetch, do you end up with just one file, or with 3 individual files, on the server?

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    You're correct on every point. I end up with 3 individual files on the server.

    Edit: I hate to pile on, but do you think it would make a difference if I used STORE vs. PUT INTO in the script. I tried to do that and Fetch appeared to access the server, but nothing was sent. How would I correctly translate the following put into command to store

    put into url "ftp://user:pass@host" item theFile format Binary

    I tried this as:
    store theFile host "host" path "theFile name" user "user" password "pass"

    The transcript shows I signed on, but no file was sent

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi Darren,

    No, using "store" wouldn't make a difference, so you shouldn't spend time on that. Stick with "put into".

    Could you please do the following?

    * Quit Fetch.
    * Run your script on a set of files.
    * Once the upload is finished, go to the Window menu, and choose Fetch Transcript.
    * Copy the entire contents of the transcript window, and paste them into a reply to this message.

    That should tell us more about what Fetch thinks it's uploading and why there might be a .zip extension on the files.

    Thanks,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

  • Hoons724 Member

    Scott, I just wanted to let you know that we sorted out the problem. It turned out to be the content of the file we were transmitting that was the problem rather than the transmission process. Fetch and Applescript are working fine in the process now that the content issues was identified and corrected. Thanks so much for all your help on all of this. I really appreciate the responsiveness. It's very refreshing.

    Darren

    Posted 3 years ago #

  • Scott McGuire Administrator

    Hi Darren,

    You're very welcome, and thanks for the followup - I'm glad to hear you got it straightened out and it's all working well now!

    Best,

    Scott McGuire
    Fetch Softworks

    Posted 3 years ago #

Reply

  • Or nickname, if you prefer.
  • This will be kept confidential.
  • This is to ensure that you’re a person, not a spambot.