7

I wrote a little shell script (on CentOS) to download statistics from our APC UPS device. It works great, but everyday cron sends an email with this message:

WARNING! 1 bare linefeeds received in ASCII mode File may not have transferred correctly.

I also get that message when I get the file manually on the shell. The FTP part of my script looks like this:

ftp -in $ftpip <<END_FTP_DOWNLOAD
user $ftpuser $ftppassword
get data.txt
bye
END_FTP_DOWNLOAD

How can I get rid of this warning message which may disturb my colleagues?

The manual FTP connection looks like this. I tried to type "ascii" this time:

220 AP9617 Network Management Card AOS v2.6.4 FTP server ready.
Name (192.168.0.50:myusername): username
331 User name okay, need password.
Password:
230 User logged in, proceed.
ftp> ascii
200 TYPE Command okay.
ftp> get data.txt
local: data.txt remote: data.txt
227 Entering Passive Mode (192,168,0,50,161,31).
125 Data connection already open; transfer starting.
WARNING! 1 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 Closing data connection.
131468 bytes received in 19,3 secs (6,6 Kbytes/sec)
ftp> bye
221 Thank you for using APC products!

The data.txt has between 500 and 800 lines and the last line is always empty.

1

2 Answers 2

11

Try to use binary mode instead of ASCII mode. It should be something like:

ftp -in $ftpip << END_FTP_DOWNLOAD
user $ftpuser $ftppassword
bin
get $filename
bye
END_FTP_DOWNLOAD
2
  • 1
    this solution works fine and seems more reliable
    – Labynocle
    Nov 10, 2014 at 17:26
  • But is close to useless for EBCDIC translation.
    – mckenzm
    May 14, 2022 at 0:49
6

Now i've found a (dirty) solution:

I download the textfile in BINARY mode and then replace the ^M character which gets inserted in the file since it looks like the APC UPS is based on DOS...

tr -d '\015' < data.txt > data-$today.txt

If someone comes up with a better solution it would be great, but this also works.

You must log in to answer this question.

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