Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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... :)

thanks.

share|improve this question

1 Answer 1

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}"
done

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!!!!!!!!! –  Digital Robot Dec 11 '12 at 5:56

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.