LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 09-20-2011, 09:04 PM   #1
hbhb
LQ Newbie
 
Registered: Apr 2007
Posts: 9

Rep: Reputation: 0
How to upload file using FTP command?


Hi,

How do I upload a file using FTP command.

The files are located inside server A. I am now connected in server A and wish to upload it to server B.

Server A: 192.168.1.1
Server B: 192.168.1.2
FTP u: admin
FTP p: admin123

From Server A:
~#ls
billing_billing.sql
~#ftp
> open 192.168.1.2
> put billing_billing.sql
local: billing_billing.sql remote: billing_billing.sql
local: billing_billing.sql: No such file or directory

So how do I upload the sql file from server A into server B?
 
Old 09-20-2011, 09:34 PM   #2
jefro
Guru
 
Registered: Mar 2008
Posts: 12,087

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
Do a dir in ftp (maybe it is ls) to show director of the ftp location that you are at. ftp is bad at paths so be sure to start ftp in the subdirectory you are in to be sure.

File permissions may also hold the file as unreadable in some cases.
 
Old 09-20-2011, 11:31 PM   #3
Lexus45
Member
 
Registered: Jan 2010
Location: Kurgan, Russia
Distribution: Slackware, Ubuntu
Posts: 339
Blog Entries: 3

Rep: Reputation: 47
Try
Code:
"put !billing_billing.sql"
or
Code:
"!put billing_billing.sql"

Last edited by Lexus45; 09-21-2011 at 12:13 AM.
 
Old 09-21-2011, 04:42 AM   #4
ostrosky.jeremiah
LQ Newbie
 
Registered: Aug 2011
Location: Pittsburgh, Pa
Distribution: Centos 6.4
Posts: 29

Rep: Reputation: Disabled
from the info you gave, it appears you are in the directory that contains the 'billing_billing.sql' file. try:

get billing_billing.sql (download to current directory on your machine)

ftp 192.168.1.2
enter your username/password
then:
put billing_billing.sql (upload to current directory on ftp server)

I know there is a way to transfer directly from one ftp server to another but exactly how that is done is escaping me right now so I'd just download it, then upload it to the other ftp server.
 
Old 09-21-2011, 08:51 PM   #5
hbhb
LQ Newbie
 
Registered: Apr 2007
Posts: 9

Original Poster
Rep: Reputation: 0
put ! and !put didn't work

ftp> put !billing_billing.sql
local: !billing_billing.sql remote: !billing_billing.sql
local: !billing_billing.sql: No such file or directory

ftp> !put billing_billing.sql
+bash: put: command not found

I'm in server A, and i'm trying to send to server B

'get' is a download. so how do I upload?
 
Old 09-21-2011, 09:30 PM   #6
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,211

Rep: Reputation: 293Reputation: 293Reputation: 293
Are you sure that you're in the directory with the file? Put is for upload, but the error looks like it can't find the file.
 
Old 09-21-2011, 09:32 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
If you are in the src dir AND you can 'see' the file to be sent AND ftp accepts the cmd, but then says it can't see the file (which appears to be the case in post#1), then it is possible that the actual filename contains one or more invisible ctrl chars (or even a space).
 
Old 09-21-2011, 09:44 PM   #8
jefro
Guru
 
Registered: Mar 2008
Posts: 12,087

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
While in the ftp command line you can show the current directory.
 
Old 09-21-2011, 11:11 PM   #9
okomba
LQ Newbie
 
Registered: Sep 2011
Location: Nairobi
Distribution: Fedora, Ubuntu
Posts: 11

Rep: Reputation: 0
Hi,

Is Server A (192.168.1.1) your local machine? If not you need to do what ostrosky.jeremiah suggested:

ftp 192.168.1.1
#enter your username/password
ftp>get billing_billing.sql #download to current directory on your machine
ftp>bye

ftp 192.168.1.2
#enter your username/password
ftp>put billing_billing.sql #upload to current directory on ftp server
ftp>bye


Cheers

Last edited by colucix; 09-22-2011 at 02:21 AM.
 
Old 09-23-2011, 11:29 PM   #10
hbhb
LQ Newbie
 
Registered: Apr 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by okomba View Post
Hi,

Is Server A (192.168.1.1) your local machine? If not you need to do what ostrosky.jeremiah suggested:

ftp 192.168.1.1
#enter your username/password
ftp>get billing_billing.sql #download to current directory on your machine
ftp>bye

ftp 192.168.1.2
#enter your username/password
ftp>put billing_billing.sql #upload to current directory on ftp server
ftp>bye


Cheers
Hi, that's what i'm trying to do.

The file billing_billing.sql is inside my server A (192.168.1.1)

I'm trying to send the file from server A (192.168.1.1) to server B (192.168.1.2)

Therefore from server A:
[192.168.1.1] #ls
billing_billing.sql <-- the file is here

[192.168.1.1] #ftp
ftp(192.168.1.1)> open 192.168.1.2
username: server2
password: *******
> put billing_billing.sql
local: billing_billing.sql remote: billing_billing.sql
local: billing_billing.sql: No such file or directory

Last edited by hbhb; 09-23-2011 at 11:30 PM.
 
Old 09-24-2011, 03:01 AM   #11
ostrosky.jeremiah
LQ Newbie
 
Registered: Aug 2011
Location: Pittsburgh, Pa
Distribution: Centos 6.4
Posts: 29

Rep: Reputation: Disabled
I believe what you are trying to do is known as FXP, or server to server transfer (site to site transfer) and although most ftp servers support it, a lot of ftp servers do not allow it (for security reasons). You may want to google an fxp client program or first check with the server admin (if possible) to see if fxp is enabled for the servers you're using. If so, the process goes something like this:

1) Create a connection to FTP server A, and another connection to FTP server B.
On FTP server A, enter passive mode (data connections will be incoming), and make a note of the servers response to the PASV command (what ip the server will be listening on, and on what port).
2) On server B, send a PORT command (data connections will be outgoing), so that the port command data corresponds to the data in FTP server A's reply to the PASV command gathered in step 2.
3) Finally, send the STOR command to ftp server A, and the RETR command to FTP server B. The data connection will be made between those two servers, and when the transfer is complete you'll be notified with a success/failure message.

Hopefully this helps but if it doesn't work you can always do as I already suggested and just GET the file from server A (to your machine) and then PUT the file to server B.

Good Luck.
 
Old 09-24-2011, 04:30 AM   #12
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
maybe you're having problems with file permissions "billing_billing.sql" either on server A (can't read it, but LS shows it) or server B not writing permissions for your username.
 
Old 09-24-2011, 03:36 PM   #13
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,212

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
since ftp is old, deprecated and insecure... is it possible for you to use scp (which runs over ssh) ?
 
Old 09-26-2011, 09:22 AM   #14
hbhb
LQ Newbie
 
Registered: Apr 2007
Posts: 9

Original Poster
Rep: Reputation: 0
I'm trying to upload a file using FTP command via SSH command line, not FTP client between servers.


There is no luck or straight answer to this issue yet for now
 
Old 09-26-2011, 09:39 AM   #15
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Please, try
Code:
!ls -l
inside the ftp session. The exclamation mark executes the command from the local shell. It should give you the listing of the current working directory in the local machine (server A).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload file to ftp server -vsftp- but can not delete or change the file once uploaded murattas6 Linux - Server 2 06-26-2009 07:00 AM
What is the FTP command to upload a folder? malcarada Linux - Newbie 2 03-18-2008 12:32 AM
How can I limit upload ftp speed via the command line? toben Linux - Software 2 02-29-2008 06:51 PM
Best way to upload (FTP) something via the command line... obelxi Linux - Networking 2 03-17-2005 07:15 PM
upload directories via ftp command farqad Linux - Networking 3 10-06-2003 09:35 PM


All times are GMT -5. The time now is 02:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration