Page 1 of 1

Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Tue Jul 02, 2013 7:09 pm
by JessieBryan
Hey guys,

I thought I would let others know what I stumbled on, while evaluating NagiosXI 2012R2.2. While using the NagiosXI web interface, there is an area that allows you to upload plugins. If you use this vs. FTP/SSH the file becomes "DOS" CR+LF formatted even if the source-file is UNIX LF formatted.

I filed the bug (#419) - this Forum post is just an FYI incase others wonder why their plugins aren't working when uploaded over the Web UI. I had to manually change the files to LF format (dos2unix or similar)

Tested with Firefox on OSX and Linux


The details can be found here: http://tracker.nagios.com/view.php?id=419

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Wed Jul 03, 2013 10:24 am
by sreinhardt
I just tested this, as this is the first report I have heard, and do not have the same issues. Are you pasting the contents of files into notepad or another windows file editor prior to uploading? Have you verified the file you started with is in fact unix line endings?

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Wed Jul 03, 2013 7:22 pm
by JessieBryan
sreinhardt wrote:I just tested this, as this is the first report I have heard, and do not have the same issues. Are you pasting the contents of files into notepad or another windows file editor prior to uploading? Have you verified the file you started with is in fact unix line endings?
Hello,

I'm actually working with a nagios migration, I scp'ed existing scripts to my linux desktop, opened my browser and uploaded them as previously described. The files before upload are properly formatted, and will run. If I look at the file uploaded files on the CLI of the NagiosXI box, they will not run unless I run "dos2unix". Multiple admins here have tested this from different OS/Browsers and got the same problem. One admin suggested it could be an Apache config.


CentOS release 6.4 (Final)
httpd-2.2.15-28.el6.centos.x86_64
NagiosXI was installed via the auto installer tarball.

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Thu Jul 04, 2013 4:58 pm
by Box293
Hi JessieBryan,
I may have come across a similar problem with another product in the past.

In my case, when using WinSCP, make sure WinSCP is configured to transfer files in text mode. If this is not correct it will add ^M to the end of each line of every file you transfer which will cause problems. I believe your problem is being caused when you SCP the files from your original location.

I hope this is of some help.

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Mon Jul 08, 2013 1:46 pm
by scottwilkerson
Yep. It can screw up the shebang line (among other things..)

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Mon Jul 08, 2013 6:17 pm
by JessieBryan
Hi guys,

In case everyone doesn't have access to the bug tracker, I thought I'd post some additional info here:


* A file on my desktop (OSX) is written in Unix (LF) format
* I upload the file using NagiosXI Web Gui "check_temp.py"
* The uploaded file on nagiosxi server is now in DOS (CR+LF) mode



We have reproduced this using Windows 7/Firefox, and OSX/Safari

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Mon Jul 08, 2013 6:18 pm
by JessieBryan
# Desktop
#
[jbryan@laptop Downloads]$ file check_temp.py
script text executablein/python


* go upload the check_temp.py file via NagiosXI Gui...
* SSH into NagiosXI server and review the results from the upload:

# NagiosXI Server
#
[nagios@monitor libexec]$ file check_temp.py
check_temp.py: a /usr/bin/python\015 script text executable

[nagios@monitor libexec]$ dos2unix check_temp.py
dos2unix: converting file check_temp.py to UNIX format ...

[nagios@monitor libexec]$ file check_temp.py
check_temp.py: a /usr/bin/python script text executable

Re: Plugin Uploads over WebUI are "DOS" CR+LF formatted

Posted: Tue Jul 09, 2013 12:22 pm
by abrist
I just tested a few different environment with a few different browsers each and could not reproduce the problem. Are you experiencing this problem with just scripts that you wrote on your mac, or have you tried to upload a script from the exchange as well?