Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
Hi there I am having problems with ftp in a terminal

How do i ftp a folder with files in from my laptop to my server. I just need to know what command to use I have looked at man ftp but i really new to this.


Many Thanks

Matt
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
unless you zip up the folder, you'll have to do it in two steps: create the remote folder, then put all the files.

the trick is to start ftp with the -i flag, which will turn off interactive mode:
Code:
% ftp -i ftp.foo.org

after you've gotten to the correct folder, you'll use mput (multiple put) instead of normal put. use wildcards to match the files in your local directory:
Code:
> mput *.html

if you leave interactive mode on, you'll be prompted for each file it finds.
 

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
Hi there Thanks for replying.

Yes I can get the put and get commands working but when I use them it only ftp's the files and not the folders.

What am I doing wrong?


MAtt
 

tyr2

macrumors 6502a
May 6, 2006
826
217
Leeds, UK
Not sure that you can do a recursive ftp put. The man page advises:

Note: mget, mput and mreget are
not meant to transfer entire directory subtrees of files.
That can be done by transferring a tar(1) archive of the sub-
tree (in binary mode)

Is there a reason you need to use the terminal? You can connect to a FTP server with Finder (Go/Connect to server), you can then drag and drop the files.
 

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
Hi there I just like using the terminal :)

If I ftp a .zip file what are the commands to unzip the archive please.


Many Thanks
 

tyr2

macrumors 6502a
May 6, 2006
826
217
Leeds, UK
Hi there I just like using the terminal :)

Yeah me too. Have you considered using 'scp' rather than 'ftp', depends if you server supports it obviously. 'scp' can handle recursive copies fine.

tidyboy said:
If I ftp a .zip file what are the commands to unzip the archive please.

You need to unzip them on the server, you can't do it via ftp. Log on to the server and just use 'unzip'
 

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
Yeah me too. Have you cinsidered using 'scp' rather than 'ftp', depends if you server supports it obviously. 'scp' can handle recursive coppies fine.



You need to unzip them on the server, you can't do it via ftp. Log on to the server and just use 'unzip'

Can you explain about scp please. And how to use commands for it
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
you are being lazy, and this is helping you. if you'd read my original post, you'd see that you can't use ftp to copy a folder and its files. i then told you how to operate ftp the way you want.

if you can't be bothered to read and/or understand responses, then we can't be bothered to try to help you.
 

yellow

Moderator emeritus
Oct 21, 2003
16,018
6
Portland, OR
Im not being lazy I am new to all this and I need help.

Well luckily, that's what man pages are for. Man being short for 'manual'.
Since you like using the command line, learning to use/read man pages is a very important skill to possess.
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,727
1,895
Lard
unless you zip up the folder, you'll have to do it in two steps: create the remote folder, then put all the files.

the trick is to start ftp with the -i flag, which will turn off interactive mode:
Code:
% ftp -i ftp.foo.org

after you've gotten to the correct folder, you'll use mput (multiple put) instead of normal put. use wildcards to match the files in your local directory:
Code:
> mput *.html

if you leave interactive mode on, you'll be prompted for each file it finds.

Hi there Thanks for replying.

Yes I can get the put and get commands working but when I use them it only ftp's the files and not the folders.

What am I doing wrong?


MAtt

You're not reading what he wrote precisely.

The man pages definitely have more information.
 

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
You're not reading what he wrote precisely.

The man pages definitely have more information.

Right I did do what zimv20 said but it did not upload the folders. Right im not being funny but like I said im new to this so a little extra detail would be handy.


Many Thanks
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
OK, say you're sitting in a directory and you have a folder called "pictures" that you want to FTP. Here's how you do it. Watch closely...

ftp myserver.com
(login as needed)
prompt
(FTP says "Interactive mode off.")
lcd pictures
(FTP says "Local directory now /blah/blah/pictures")
mkdir pictures
(FTP says "pictures: the directory was successfully created")
cd pictures
(FTP says "OK. Current directory is /www/blah/pictures")
mput *
(FTP uploads every file in the directory)

Make sense now?
 

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
OK, say you're sitting in a directory and you have a folder called "pictures" that you want to FTP. Here's how you do it. Watch closely...

ftp myserver.com
(login as needed)
prompt
(FTP says "Interactive mode off.")
lcd pictures
(FTP says "Local directory now /blah/blah/pictures")
mkdir pictures
(FTP says "pictures: the directory was successfully created")
cd pictures
(FTP says "OK. Current directory is /www/blah/pictures")
mput *
(FTP uploads every file in the directory)

Make sense now?

Hi there thanks for replying

I understand what you are saying in your example but what I am tyring to do is ftp the invision power board forum software files to my server.

I need to keep the directory structure so how do I ftp the whole thing over.
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
Hi there thanks for replying

I understand what you are saying in your example but what I am tyring to do is ftp the invision power board forum software files to my server.

I need to keep the directory structure so how do I ftp the whole thing over.

You are in for a long night.

mkdir forum
cd forum
lcd forum
mput *
mkdir bin
cd bin
lcd bin
mput *
cd ..
lcd ..
mkdir images
cd images
lcd image
mput *
...

And so on. One set of mkdir/cd's/mput's for every single directory. And don't forget to chmod the directories correctly, some will be 755, some 777... don't get that wrong or you'll have a non-working board, or a huge security risk, or both.

I've done it. It's tedious. Do you REALLY want to use the terminal ftp for this? You should consider a GUI app that will take care of that for you, or scp, or... something.
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,727
1,895
Lard
Hi there thanks for replying

I understand what you are saying in your example but what I am tyring to do is ftp the invision power board forum software files to my server.

I need to keep the directory structure so how do I ftp the whole thing over.

Look for Cyberduck on http://www.macupdate.com/ or http://www.versiontracker.com/ and download and install it. Then, run it, set up your server information and log into that server. Then, drag the folder to where you want it to be on the server.

It'll be a lot easier for you and the software is free and reliable.
 

tidyboy

macrumors newbie
Original poster
Dec 10, 2006
18
0
Coventry UK
You are in for a long night.

mkdir forum
cd forum
lcd forum
mput *
mkdir bin
cd bin
lcd bin
mput *
cd ..
lcd ..
mkdir images
cd images
lcd image
mput *
...

And so on. One set of mkdir/cd's/mput's for every single directory. And don't forget to chmod the directories correctly, some will be 755, some 777... don't get that wrong or you'll have a non-working board, or a huge security risk, or both.

I've done it. It's tedious. Do you REALLY want to use the terminal ftp for this? You should consider a GUI app that will take care of that for you, or scp, or... something.

Thanks thats what I thought :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.