Please help fixing this NON WORKING script

Discussion in 'Mac Programming' started by etnad, Nov 27, 2012.

  1. etnad, Nov 27, 2012
    Last edited by a moderator: Nov 27, 2012

    macrumors newbie

    Joined:
    Sep 23, 2012
    #1
    This isn't a working script but I hope someone can kindly fix it for me. is only what I would like to get based on another script which reads the first line in a tet file.
    After this "non working Script" you will find additional explanation about my process

    I am using Snow Leopard because of the lack of Rosetta in the various Lions (due to the indifference form Apple computers to renew the Rosetta licence held by PowerPC IBM [mysteries of computer companies deals]

    Code:
    set theDoc to choose file with prompt "Select:"
    tell application "TextWrangler"
       set theDoc to document 1
       set parag to (count of paragraphs of text of theDoc)
           set Para to parag - 1
               select paragraph Para of theDoc
               if Para contains :"Myserverita"
               tell application "transmit"
               activate 
               connect to favirite "Myserverita"
               end tell
               exit script
              if Para contains :"MyserverOther"
               tell application "Safari"
               activate 
               end tell
               exit script
               else if
               Content Para contains :"MyserverFrance"
               tell application "speedownload"
               activate 
               end tell
               exit script
               else if
               Content Para contains :"MyserverGermany"
               tell application "Rapidshare Manager"
               activate 
               end tell
               exit script
     
    end tell

    Why I need this?

    I need to upload download various large files often over 100 GB of space (mainly tentive film editing) and receive changes on the files.
    All this happens either through ftp as we all have servers or most frequetly using the filesharing services such as rapidshare and so on, or news servers

    Each series of files consists in Rar segments and PAR2 files to fix possible transmission errors. Each file is password protected as only my coworker world wide can load them.

    The files are so very large because they are "raw" files, and often include FinalCUtPro additional data in video and sound.

    Some of these apps are in Java and they do not have Applescript support at all, however I hope the Finder will still be able to activate them

    Once opened the various apps willl be opened I will manually perform what is necessary to either upload or download the various files.

    I'am aware of professional applications "srot of" doing this already: however they do not suit my needs. Any confrntation on this matter is beyond my request which I hope will not bother anybody. In my country Internet is very slow and I have no choice.
    Because of this I need to use 2 or 3 mqachines and two or 3 different Interent lines else my router becomes an electric turtle and really I can only barely use internet

    As I might be not too clear please let me know and I will organize this request again ....

    Thanks a lot
     
  2. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Although TextWrangler is a nice application you don't need it to read a text file within Applescript. You're telling application transmit to connect. Is transmit scriptable? Does it understand the connect statement? If you want to check if Para contains :Myserverita you should put the colon inside the quotes. Can you attach the text file you want to read to your post?
     
  3. etnad, Nov 27, 2012
    Last edited by a moderator: Nov 27, 2012

    thread starter macrumors newbie

    Joined:
    Sep 23, 2012
    #3
    ìthanks:
    Yes Transmit is scriptable and these are the dictionary voices I believe I should use:

    Code:
    connect v : Connect to a favorite or a specified server.
    connect
    [to favorite] : The favorite to connect to.
    [to address text] : The address to connect to.
    [as user text] : The user name to use when connecting.
    [using port integer] : The network port to use when connecting.
    [with initial path text] : The initial path to change to after the connection is made.
    [with password text] : The password to use when connecting.
    [with protocol FTP/FTP implicit SSL/FTP TLS SSL/S3/SFTP/WebDAV/WebDAV HTTPS] : The connection type to use when connecting.
    [mount boolean] : Try to mount the disk in the Finder.
    → boolean : Whether the connection was successful.

    Code:
    favorite n : A favorite in Transmit.
    elements
    contained by application.
    properties
    address (text, r/o) : The address of the favorite.
    local path (text, r/o) : The local path for the favorite.
    password (text, r/o) : The password for a favorite.
    port (integer, r/o) : The port to connect to for a favorite.
    protocol (FTP/FTP implicit SSL/FTP TLS SSL/S3/SFTP/WebDAV/WebDAV HTTPS, r/o) : The protocol a favorite uses to connect.
    remote path (text, r/o) : The remote path for a favorite.
    name (text, r/o) : The name of a favorite.
    URL (text, r/o) : The root URL specified for a favorite.
    user name (text, r/o) : The user name for a favorite.
    identifier (text, r/o) : The unique identifier for a favorite.



    this is a short example file pls consider most text flles are basically the same:


    http://rapidshare.com/files/839936239/IM_here.avi.001
    http://rapidshare.com/files/2008072689/IM_here.avi.002
    http://rapidshare.com/files/1985424796/IM_here.avi.003
    http://rapidshare.com/files/4260995399/IM_here.avi.004
    http://rapidshare.com/files/2964792817/IM_here.vol000+01.par2


    these files are ot available as I erased them frm the server already, but they are legitimate and exact copies for what I need todo.

    in this case I uploaded this short file (the list is not complete)
    what matters for the script I hope to use is the first paragraph. In this case you read:
    http://rapidshare.com
    this should pop open the "speed dowload" application which is indeed scriptable but as such it has no use to me because once opened i can instantly paste the whole text file, and choose in one click if I want to upload it and to who, or download it

    in other words the script might call different applications as every server uses faster certain transfer option, not all use FTP and not all use "speed download" (again scriptable, but so well furnished in terms of short cuts that just opening is fine)
    Other apps are Java only so again al I need is to have it opened and then I will do whatever i need manually
     
  4. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    Try and change where needed :


    Code:
    set theDoc to choose file with prompt "Select your txt file to read:"
    -- The first paragraph of theDoc
    set theParagraph to first paragraph of (read theDoc)
    -- Act on the first paragraph
    if theParagraph contains "rapidshare" then
    	tell application "speedownload" to activate
    else if theParagraph contains "something else than rapidshare" then
    	tell application "Rapidshare Manager" to activate
    else if theParagraph contains "something else than rapidshare" then
    	tell application "Safari" to activate
    else if theParagraph contains "something else than rapidshare" then
    	tell application "transmit"
    		activate
    		connect to favorite "whatever favorite"
    	end tell
    end if
    
     

Share This Page