help! need a cli command to send files to ftp

Posted:
in macOS edited January 2014
I'd like a one line command to send files to a specific directory on a remote ftp server. I'd like to add this to the On My Command contextual menu so that I can right click a file and select 'ftp to pictures directory', or some such, and have it ftp over. i have an account on the ftp server and dont' want to have to enter my pw - i realize the security risks of this.

Comments

  • Reply 1 of 8
    pyr3pyr3 Posts: 946member
    I believe that this command will work :



    > ftp -u ftp://usernameassword@hostort/path/to/folder/ file1.txt file2.txt file3.txt



    This would upload those 3 files to the path on the host.
  • Reply 2 of 8
    cybermonkeycybermonkey Posts: 604member
    like pyr said the ftp command in built in just type ftp in terminal to open it. then type help for a full list of commands
  • Reply 3 of 8
    pyr3pyr3 Posts: 946member
    Quote:

    Originally posted by cybermonkey

    like pyr said the ftp command in built in just type ftp in terminal to open it. then type help for a full list of commands



    What he's looking for is something that will do it all in one command, which means that he won't be using interactive mode.
  • Reply 4 of 8
    serranoserrano Posts: 1,806member
    Ok, thanks pyr3, after a little fumbling I've got it.

    I have to cd to the directory the file is in first. Then

    Code:




    ftp -u ftp://user[email protected]/mysite/pictures/ thefile.jpg







    and all on one line...

    Code:




    cd /path/to/; ftp -u ftp://user[email protected]/mysite/pictures/ thefile.jpg













    In on my command it looks like this...

    Code:




    cd __OBJ_PARENT_PATH__; ftp -u ftp://user[email protected]/mysite/pictures/ __OBJ_NAME__









    It's really quite a powerful tool, I recommend it to anyone who does even slight cli work. There's also a quite powerful 3rd party gui editor.

    OnMyCommandCM 1.5.2

    OMCEdit 1.5
  • Reply 5 of 8
    Yes I use this all the time, I was looking for something to create blank text files for EVER! then I got this and first thing I did was write one to use the touch command
  • Reply 6 of 8
    boemaneboemane Posts: 311member
    Quote:

    In on my command it looks like this...

    Code:




    cd __OBJ_PARENT_PATH__; ftp -u ftp://user[email protected]/mysite/pictures/ __OBJ_NAME__










    This only half-works. I tried it out on my FTP server, and it works if I choose to do it in the terminal (it opens up a new terminal window, and executes the commands there), but it doesn't work if I choose the script to be silent. Finder just hangs for a while, and nothing happens.



    Im using the exact same script as you pasted, only with some changes to the values for pass, user, server and path.



    Am I doing something wrong here ?



    EDIT: I thought, maybe if I use Silent, I can only use one command at a time, and the script above sends two (the first is the cd command, the second is the ftp)



    SO I figured I could change it to one command to make it work:



    ftp -u ftp://user: [email protected]/path/to/__OBJ_NAME__ __OBJ_PARENT_PATH__/__OBJ_NAME__



    But this command also only works if its not set to silent. Is this a bug in the application ? I would think that it should work either way, now!



    Any suggestions?





    .:BoeManE:.
  • Reply 7 of 8
    serranoserrano Posts: 1,806member
    I can't get either to work in silent mode.



  • Reply 8 of 8
    mokimoki Posts: 551member
    Quote:

    Originally posted by pyr3

    What he's looking for is something that will do it all in one command, which means that he won't be using interactive mode.



    Regardless of whether you enter your password interactively, or all in one line in the ftp URL, you still send your password via cleartext to the server.



    So if you're trying to do this for security reasons, don't bother.



    A better alternative is to use sftp (assuming the server you're uploading to supports it). Open up Terminal and type:



    man sftp



    ...for more info. It's essentially a secure version of ftp
Sign In or Register to comment.