For the Terminal MASTERS

jomaan

Super Bull
Anyone knows how can I change the download location when I use the ftp service in terminal?
Ftp all the times downloads archives in my user folder… I whana download in a diferent disk… any ideas???

thx:confused:
 
The command line ftp program will use the current directory for sending and receiving files. This directory is of course your home directory if you've just opened a new Terminal window. You can use the cd command to change directories. Just type 'cd directory' to switch. The other volumes are mounted inside of /Volumes, so go there, type ls to see the names of the volumes, and use cd again to get inside of one of them.

These are just some quick and dirty instructions, so if you need any further explanations of what this all means, you're probably best off looking for a simple UNIX tutorial on the internet. Just look for something that covers the basics of directory navigation, running programs, and things like that.
 
The command line ftp downloads to whatever your current working directory is. When you first launch a shell (aka: start the terminal) your working directory is your home directory. You can determine what your current working directory is by typing "pwd" (Print Working Directory).
So, you can simply change to the download directory first, then run ftp. this is done with the "cd" command (see "man cd" for more info). The actual command should look something like this:

cd /Volumes/some_disk/downloads

pwd will then yield:
/Volumes/some_disk/downloads.

A couple of notes:
If you are changing to a directory within your home directory (a great example being "desktop") you can give cd what's known as a relative path name (as opposed to an absolute path name, like the one in the previous example). You can tell a relative pathname because it does not start with a "/". This tells the shell to start looking in the current directory, rather than at the top of the filesytem (aka the root of the file system, aka "/")
So, assuming you are starting out in your home directory, these two commands yield the same result:

cd /Users/home-dir/desktop/downloads
or
cd desktop/downloads

However, if you are in some other directory (not your home) then only the first one would work. The first one is absolute; it's a roadmap to that directory from anywhere on the system. The second is relative to your home directory.

The other thing to keep in mind is that the shell doesn't like spaces in the path, so if you have a folder like:
/Volumes/My Disk/Download Folder
and you try to type:

cd /Volumes/My Disk/Download Folder

it won't work. This is because the shell uses the space character to seperate different parts of the command. To make it work, you should preceed each space with a "\" (that's a back-slash). This is called "character escaping" and it tells the shell to treat the space as a literal space, and not as a seperator. (it's worth noting that other special characters like "*" also need to be escaped). So in our example of a path with spaces, the actual command is:

cd /Volumes/My\ Disk/Download\ Folder

Got all that? OK, there's one last thing. Let's say that you already started ftp from the wrong directory, or you want to download to several different directories, what then?
All the things I mentioned (cd, pwd, and character escaping) also work within the command line ftp. You probably already know this if you've been using ftp. What you may not know is that if you add a lower case "L" to the begining of those commands (ie: lpwd, lcd) it changes the meaning to "local" (so, local-cd, local-pwd, etc...). So you can still change your _local_ directory from within ftp, even if you forgot to do it before connecting. The lcd command within ftp works just like the cd command in the shell:
ftp> lcd /Volumes/My\ Disk/Download\ Folder
ftp> local directory is now: /Volumes/My Disk/Download Folder
(and of course, within ftp, plain old "cd" changes your directory on the _remote_ system).

That just about covers evrything you need to know. Just remember, the man pages are your friend. try typing:
man ftp
man ls
man cd
in the terminal.

Hope this helps...

-alex
 
You can also try out the nifty 'ncftp' CLI ftp client. Its workings are similar to the plain vanilla 'ftp', but slightly more intuitive.


dani++
 
While we're tossing out useful nuggets:
At the Darwin command line, you can cd into folders with embedded spaces by enclosing the whole dirname in quotes.

At the ftp command line, you can enter a ? to get a list of all commands, and ? (commandname) to get a brief description of an ftp subcommand.
 
from within the cli ftp client, you can also issue a "lcd dir" to change your working directory to the new dir. Very usefull if you forgot the change dir's before you started up ftp. You can also issue a "lls" to get a listing of the current working directory if you need to.
 
What you need is the FTP command 'lcd' for Local Change Directory.
Like so:

lcd /Users/Me/Downloads
 
Back
Top