how to use ftp(1) in batch mode

Wojciech Puchar wojtek at puchar.net
Fri Aug 31 13:53:10 UTC 2018


thank you. it works. actually even without netrc

(echo command1;echo command2)|ftp ftp://user:password@server/

On Thu, 30 Aug 2018, Eugene Grosbein wrote:

> On 30.08.2018 19:50, Wojciech Puchar wrote:
>> i want to delete all say *.foo files on remote ftp server
>>
>> while it's clear how to download file using ftp(1) in batch mode, i cannot
>> figure how to delete files in batch mode without any keyboard interaction.
>>
>> Could you help
>
> $ echo "machine localhost login ftp password user@" >> ~/.netrc
> $ printf "cd incoming\nprompt off\nmdel *.foo\nquit\n" | ftp localhost
> Connected to localhost.
> 220 host.xxx FTP server (Version 6.00LS) ready.
> 331 Guest login ok, send your email address as password.
> 230- Your welcome message here.
> 230 Guest login ok, access restrictions apply.
> Remote system type is UNIX.
> Using binary mode to transfer files.
> 250 CWD command successful.
> Interactive mode off.
> 250 DELE command successful.
> 250 DELE command successful.
> 250 DELE command successful.
> 221 Goodbye.
>
> But, you better use ncftp3 port/package for such jobs.
>
>


More information about the freebsd-hackers mailing list