Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Linux command line FTP

  • 14-12-2005 11:24PM
    #1
    Registered Users, Registered Users 2 Posts: 1,086 ✭✭✭


    Anyone know how to copy via FTP on linux command line multiple directories and not just multiple files.

    At present I am using the 'mput' command but I don't think this works for directories and their contents.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 944 ✭✭✭SwampThing


    You'll have to cd into each directory and do and mput for the files in each directory.

    You could write a wee shell script to do it -

    ftp to server; cd to top directory; do a 'list' command out to a file; use this list file to control a 'for loop' which loops thru each direcroty in the list and does the mput command for each directory.

    If you need a hand, let me know


  • Registered Users, Registered Users 2 Posts: 1,086 ✭✭✭Peter B


    Thanks for the info.
    Wouldn't know where to start though. What language would you write it in? Would you need a recursive function or something similar to copy sub-folders and sub-sub-folders?

    Anywhere on the web I could find an already completed script?


  • Closed Accounts Posts: 12,807 ✭✭✭✭Orion


    Write a command line script. FTP is OS-independent - the commands are the same no matter what OS you are using. What SwampThing suggested is the best/(only) way to do it from the command line.


  • Registered Users, Registered Users 2 Posts: 1,086 ✭✭✭Peter B


    Any help with a command line script would be greatly appreciated.


    Need some sort of loop where after connection in root directory...

    function LS()
    ls command in local server

    ****loop for each result
    {
    if (directory)
    {
    mkdir directory_name;
    cd directory_name;
    run function LS();
    }
    else ***not a directory
    {
    ftp file to current directory position;
    }
    }
    ****end loop



    end connection


    Is this a similar structure?


  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    Install ncftp on the machine and do a get -R <directory> to recursively copy directories.

    noticed you mentioned command line.. if u are doing it in a script ncftpget is the command line version of it too..


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    lynchie ftw. You lot with your complicated scripts and recursion malarky. :P


  • Registered Users, Registered Users 2 Posts: 1,086 ✭✭✭Peter B


    Well the problem is I am copying files from an old college account to my webspace. My webspace is not supposed to have ssh access even though I can access the command line when I connect through command line from my old college account using 'ftp ftp.myaccount.com'.

    Will it be possible to install these programs on my college account or will I have to contact the administrator?

    How will I know is ncftpget is installed or not?


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    That's not a shell command line you're at...it's an ftp command line.

    What you want to do at your college login is:

    which ncftp (will tell you where it is)

    and

    ncftp yourdomain.ie

    will connect you.


Advertisement