Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

While making an automated ftp upload script, I noticed a very strange behaviour of ftp program: if I want to send a file which belongs to /tmp directory, ftp will always fail and give an error message: cannot create file.

See this:

^_^ ~ > touch /tmp/file1

^_^ ~ > touch file2

^_^ ~ > ftp <server>
Connected to <server> (<server ip>).
220 (vsFTPd 2.2.2)
Name (<server:username>): <username>
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

ftp> put /tmp/file1
local: /tmp/file1 remote: /tmp/file1
227 Entering Passive Mode (<ip>).
553 Could not create file.

ftp> put file2
local: file2 remote: file2
227 Entering Passive Mode (<ip>).
150 Ok to send data.
226 Transfer complete.
ftp> 

What is wrong with ftp reading a file from /tmp?

There is no SELinux or AppArmor on the server nor on the ftp client.

share|improve this question
    
Does the /tmp directory exist on the ftp server and do you have access to it? Can you cd into both the remote and local /tmp directories and put file1? –  Nicole Hamilton Feb 21 '13 at 0:24
add comment

3 Answers

up vote 1 down vote accepted

The problem isn’t reading the file from /tmp –– read the error message: “553 Could not create file.”  When you say

put a_single_file_name

that is equivalent to

put  single_file_name   that_same_file_name_again

So put /tmp/file1 is equivalent to put /tmp/file1 /tmp/file1, and this fails if the FTP server doesn’t have a writable /tmp directory configured.  Try put /tmp/file1 file1, or maybe put /tmp/file1 ./file1.

share|improve this answer
    
thanks, that makes lot of sense –  Howard Feb 21 '13 at 9:33
add comment

Note that when you run ftp you are connected to a remote machine. Use the lcd to change directories on your local machine; cd will change directories on the remote machine. In your case

lcd /tmp
put file1
lcd <to original directory>
share|improve this answer
add comment

Use ls -l to view the permissions on the folder. Does the user you authenticate as have write access to that directory? If not, you need to use chmod to ensure that it does, or it will never work.

Often, FTP accounts have limited access to areas close to / In fact, some systems are set up so they can ONLY write to /home/ftpUserName

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.