Script for Uploading to FTP Server

Discussion in 'Mac Programming' started by thriftinkid, Mar 27, 2008.

  1. thriftinkid macrumors regular

    Mar 24, 2008
    Hey guys,

    I trying to write two applescripts where one will reference the other for login info.

    Basically, I want to use this to upload files onto an ftp server, but I want it to be flexible so I can use it on multiple systems.

    This is what I'm looking to do:

    Script 1: (All Info Should be Saved For Reference for Script 2)

    1. Ask for Host name
    2. Ask for User Name
    3. Ask for Password.
    4. Ask for port number
    5. Startup FTP Application (Use info above and actually login)
    5. Ask for destination upload folder
    6. Save all info
    7. Logout and quit application

    Script 2: (To be used on selected file to upload)

    1. Startup FTP Server application
    2. Reference Script 1 for login info
    3. Login.
    4. Reference Script 1 for destination upload folder
    5. Upload file
    6. Log Out and Quit.

    Any ideas on where to get started, or where I can go to find help? I've never written code, and I am learning on the fly. Thanks Guys!
  2. ChrisA macrumors G4

    Jan 5, 2006
    Redondo Beach, California
    I think you ment "Startup FTP client ..."
    I think many FTP clients will look for a file called .netrc and use usernames and passwords found in there. I don't like .netrc files for security reasons but if you are going to be storing this information this is the place because the any FTP client will know were to look. Go to the terminal and "man ftp" should explain this.

    So your first script woud really be an editor for .netrc files
  3. thriftinkid thread starter macrumors regular

    Mar 24, 2008
    I'm trying to do it in one script because it will be storing other usernames and passwords for other applications as well to reference, and I want the user to be able to put all the information in at once instead of having to run multiple reference scripts. Any way I could do that?
  4. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    I am not sure if keychain access is available from AppleScript, but that's what I would try. The keychain is designed to keep a database of usernames and passwords.

  5. ChrisA macrumors G4

    Jan 5, 2006
    Redondo Beach, California
    Yes. You can read were I said I really do not like .netrc files. In fact if Apple script can't access the keychain I'd recommend abandening Applescript for this project and using something that can.

    I thought that all you were doing was uploading some files to an FTP server. That's nearly trivel a one line script could do that if you used the .netrc idea but now you say there are other things to be done. It's a very bad idea to store passwords.

Share This Page