Discussion:
how to use ftp(1) in batch mode
Wojciech Puchar
2018-08-30 12:50:19 UTC
Permalink
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
Eugene Grosbein
2018-08-30 13:26:27 UTC
Permalink
Post by Wojciech Puchar
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.
Wojciech Puchar
2018-08-31 13:52:45 UTC
Permalink
thank you. it works. actually even without netrc
Post by Eugene Grosbein
Post by Wojciech Puchar
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
$ 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.
Eugene Grosbein
2018-08-31 14:01:24 UTC
Permalink
Post by Wojciech Puchar
thank you. it works. actually even without netrc
You better not develop a habit typing passwords in command line or URLs, this is quite insecure.
Mario Lobo
2018-08-31 17:55:20 UTC
Permalink
Post by Eugene Grosbein
Post by Wojciech Puchar
thank you. it works. actually even without netrc
You better not develop a habit typing passwords in command line or URLs,
this is quite insecure.
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
I believe that using sftp with authorized keys in batch mode is safer. The
batch file would only need to have the actual commands.

The only drawback for this method to be fully non-interactive is that you
have to take out the passphrase from the private key.
--
Mario Lobo
http://www.mallavoodoo.com.br
FreeBSD since version 2.2.8 [not Pro-Audio.... YET!!]
Wojciech Puchar
2018-08-31 18:36:28 UTC
Permalink
I believe that using sftp with authorized keys in batch mode is safer. The batch file would only need to have the actual commands.
with ssh available on remote server i would simply use ssh.
but i don't administer remote server
The only drawback for this method to be fully non-interactive is that you have to take out the passphrase from the private key.
--
Mario Lobo
http://www.mallavoodoo.com.br
FreeBSD since version 2.2.8 [not Pro-Audio.... YET!!]
Wojciech Puchar
2018-08-31 18:37:48 UTC
Permalink
Post by Eugene Grosbein
Post by Wojciech Puchar
thank you. it works. actually even without netrc
You better not develop a habit typing passwords in command line or URLs, this is quite insecure.
why it is less secure as long as it is my account with
security.bsd.see_other_uids=0 set on server or even my own computer.
Ian Lepore
2018-08-31 18:46:27 UTC
Permalink
Post by Eugene Grosbein
Post by Wojciech Puchar
thank you. it works. actually even without netrc
You better not develop a habit typing passwords in command line or
URLs, this is quite insecure.
why it is less secure as long as it is my account with 
security.bsd.see_other_uids=0 set on server or even my own computer.
My advice: Just ignore them. A certain type of person simply cannot
resist lecturing about security, even when they know absolutely nothing
about your application or context.

-- Ian
Eugene Grosbein
2018-08-31 19:13:09 UTC
Permalink
Post by Ian Lepore
Post by Wojciech Puchar
why it is less secure as long as it is my account with
security.bsd.see_other_uids=0 set on server or even my own computer.
My advice: Just ignore them. A certain type of person simply cannot
resist lecturing about security, even when they know absolutely nothing
about your application or context.
That's not about a protocol, installation or context but about bad habits it general.
Yes, I know ftp can be pretty secure if runs over IPSEC etc. and I sometimes do so.
That does not make a habit to include a password into URLs a good habit.
Ian Lepore
2018-08-31 19:22:38 UTC
Permalink
Post by Eugene Grosbein
Post by Ian Lepore
why it is less secure as long as it is my account with 
security.bsd.see_other_uids=0 set on server or even my own
computer.
My advice: Just ignore them. A certain type of person simply cannot
resist lecturing about security, even when they know absolutely nothing
about your application or context.
That's not about a protocol, installation or context but about bad habits it general.
Yes, I know ftp can be pretty secure if runs over IPSEC etc. and I sometimes do so.
That does not make a habit to include a password into URLs a good habit.
LOL, thank you for making my point most eloquently.  Y'all just REALLY
can't resist lecturing, can you?

-- Ian
Eugene Grosbein
2018-08-31 20:18:41 UTC
Permalink
Post by Eugene Grosbein
Post by Ian Lepore
My advice: Just ignore them. A certain type of person simply cannot
resist lecturing about security, even when they know absolutely nothing
about your application or context.
That's not about a protocol, installation or context but about bad habits it general.
Yes, I know ftp can be pretty secure if runs over IPSEC etc. and I sometimes do so.
That does not make a habit to include a password into URLs a good habit.
LOL, thank you for making my point most eloquently. Y'all just REALLY
can't resist lecturing, can you?
You are saying "lecturing" like that's something wrong with free lecture :-)
Wojciech Puchar
2018-09-01 11:26:30 UTC
Permalink
Post by Eugene Grosbein
Post by Eugene Grosbein
That does not make a habit to include a password into URLs a good habit.
LOL, thank you for making my point most eloquently. Y'all just REALLY
can't resist lecturing, can you?
You are saying "lecturing" like that's something wrong with free lecture :-)
yes - if nobody ask for it.
Wojciech Puchar
2018-09-01 11:25:46 UTC
Permalink
Post by Ian Lepore
why it is less secure as long as it is my account with 
security.bsd.see_other_uids=0 set on server or even my own computer.
My advice: Just ignore them. A certain type of person simply cannot
resist lecturing about security, even when they know absolutely nothing
about your application or context.
Seems like. It's like linux fanatics that don't use rsh/rlogin (it's often
not even available in their distros) "because it's insecure".

I regularny use rsh, rcp and rlogin on my LAN and over my VPN's because
it's fast and simple.
Eugene Grosbein
2018-08-31 18:46:31 UTC
Permalink
Post by Eugene Grosbein
Post by Wojciech Puchar
thank you. it works. actually even without netrc
You better not develop a habit typing passwords in command line or URLs, this is quite insecure.
why it is less secure as long as it is my account with security.bsd.see_other_uids=0 set on server or even my own computer.
I'm talking not about ftp protocol or your installation here
but about developing bad habits in general.
Wojciech Puchar
2018-09-01 11:24:30 UTC
Permalink
Post by Eugene Grosbein
Post by Eugene Grosbein
You better not develop a habit typing passwords in command line or URLs, this is quite insecure.
why it is less secure as long as it is my account with security.bsd.see_other_uids=0 set on server or even my own computer.
I'm talking not about ftp protocol or your installation here
but about developing bad habits in general.
there are no "bad habits in general". Everything depends on situation.
Eugene Grosbein
2018-09-01 14:45:12 UTC
Permalink
Post by Wojciech Puchar
Post by Eugene Grosbein
Post by Eugene Grosbein
You better not develop a habit typing passwords in command line or URLs, this is quite insecure.
why it is less secure as long as it is my account with security.bsd.see_other_uids=0 set on server or even my own computer.
I'm talking not about ftp protocol or your installation here
but about developing bad habits in general.
there are no "bad habits in general". Everything depends on situation.
There are bad habits in general and a password in an URL is just an example.
Jamie Landeg-Jones
2018-09-01 12:26:12 UTC
Permalink
Post by Wojciech Puchar
thank you. it works. actually even without netrc
If you need something slightly more robust, you may want to look
at lang/expect, which uses send/expect sequences similar to kermit
and uucp, but with more powerful options:

man expect(1):

| Expect is a program that "talks" to other interactive programs according to a
| script. Following the script, Expect knows what can be expected from a program and
| what the correct response should be. An interpreted language provides branching and
| high-level control structures to direct the dialogue. In addition, the user can
| take control and interact directly when desired, afterward returning control to the
| script.

cheers, Jamie
Wojciech Puchar
2018-09-01 17:01:27 UTC
Permalink
Post by Jamie Landeg-Jones
Post by Wojciech Puchar
thank you. it works. actually even without netrc
If you need something slightly more robust, you may want to look
at lang/expect, which uses send/expect sequences similar to kermit
yes i've used it few times. thanks
Post by Jamie Landeg-Jones
| Expect is a program that "talks" to other interactive programs according to a
| script. Following the script, Expect knows what can be expected from a program and
| what the correct response should be. An interpreted language provides branching and
| high-level control structures to direct the dialogue. In addition, the user can
| take control and interact directly when desired, afterward returning control to the
| script.
cheers, Jamie
Continue reading on narkive:
Loading...