Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am connecting to my server via FTP (that is the only way I have access to this server in particular). I need to utime a command via FTP to the server. Other commands work but when I try something like

site for file in *;do utime 20120101084400 ${file}; done;

to change all dates in a given directory, I receive an error that says usage: form format or invalid command depending on the variation of that command I try.

I tried this command (without the site part) on my local unix and it works but not remotely via FTP.

How do I do that? If there's a way to do that recursively it will be a bonus... :)


share|improve this question
up vote 2 down vote accepted

Allowed SITE commands vary with the FTP daemon in use (like, SITE CHMOD in vsftpd; some more in Apache's FtpServer). In general, it's not the remote shell facility you seem to expect. However, ProFTPd apparently supports SITE UTIME.

So if your FTPd in question has SITE UTIME, you could try to SITE UTIME in a client-side loop, like this (pseudo-code, no server mentioned, also keep in mind that there might be spaces (needs quotation); also you'd need a versatile FTP client (lftp might be a good candidate)):

for file in $(./ftp-get-directory-list)
  do ftp-client -c "SITE UTIME ${file}"

EDIT also see Gilles' nice answer here on the possible interaction between Bash scripts and lftp.

Addendum If you're into some scripting language (e.g. Python), you could also do yourself a favor by using some FTP library.

share|improve this answer
thanks. This is perfect!!!!!!!!! – SpaceDog Dec 11 '12 at 5:56

Your Answer


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.