2

I typically use the bash command line when I need to FTP something. I have found that certain FTP servers are not set to binary mode by default and unless I remember to do so, the file sent will be corrupt. Is there a way to set binary mode automatically every time I access a remote ftp server?

3
  • Why not issue 'bin' each time you do an upload?
    – t0mm13b
    Dec 13, 2009 at 19:17
  • Very good question! I have just strace'ed the ftp command. I see that ftp reads .netrc, but unfortunately netrc supports only username/passwd AFAIK.
    – Vokuhila-Oliba
    Dec 13, 2009 at 19:32
  • Steven - if someone answers this question with an expect script, would you then have to migrate that answer back to SO? Dec 13, 2009 at 19:44

2 Answers 2

3

If you want to use ftp, then you can put arbitary commands into the netrc by defining a macro. If the macro is called init, then it will be automatically executed, like this

machine server
login user
password password
macdef init
binary

Any commands between the macdef line and the blank line will be executed as soon as the login is complete.

1
  • Thanks. This is exactly the answer I was looking for. I simply created .netrc and added binary, tested, and it works as you said. However, I am really liking ncftp now, which will be my new ftp client. Dec 14, 2009 at 7:29
0

Use ncftp, which defaults to binary.

1
  • Thanks for the ncftp tip. I love the bookmark feature as well. Dec 13, 2009 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .