LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2010, 03:47 PM   #1
Schadrach
LQ Newbie
 
Registered: Dec 2007
Posts: 10

Rep: Reputation: 0
wget seems to add extra newlines on output to serial port?


I need to read some data from a web server and output to a serial port on the local machine. I was attempting to use the following command:

Code:
wget -q -O/dev/ttyS0 http://<IP address>/<filename>.asp?LID=12345
But the device attached to the serial port (a plate embosser) acts as though there is an extra newline after each line of data.

It parses the data sent according to it's own format, which includes a format string in <> followed by a data block containing one data field per line, with the whole block surrounded by <>, for example:

Code:
<]01Y425X472 Y55X50F0 Y110X50F0 Y165X50F0 Y220X50F0 Y55X250F0 Y275X50F0 Y330X50F0 Y330X180F0 Y330X180F0 Y385X50F0 Y385X330F0 Y275X290F0 Y330X290F0>
<0501175
OX-31160/XCM6090
Y-BFW-7155-A34A-SH1
Y-7155-BFW-16
AREA Y
NONE
.
. .
 
. 1 OF 5
12345
.
.>
seems to output as though it were:

Code:
<]01Y425X472 Y55X50F0 Y110X50F0 Y165X50F0 Y220X50F0 Y55X250F0 Y275X50F0 Y330X50F0 Y330X180F0 Y330X180F0 Y385X50F0 Y385X330F0 Y275X290F0 Y330X290F0>

<0501175

OX-31160/XCM6090

Y-BFW-7155-A34A-SH1

Y-7155-BFW-16

AREA Y

NONE

.

. .

 

. 1 OF 5

12345

.

.>
I can verify that the web server is outputting the former (and it looks correct if I send the wget output to console).
 
Old 10-05-2010, 09:57 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,293

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Hi

Since there is .asp in the link I guess you get the data from a Windows server. The end of line is different on Windows, so my guess is you need to translate it. There is a command called dos2unix that does this. You might need to install it. On Debian/Ubuntu it's in a package called tofrodos. Then you can use a command like this:

Code:
wget -q -O- http://<IP address>/<filename>.asp?LID=12345 |dos2unix >/dev/ttyS0
 
Old 10-05-2010, 03:59 PM   #3
Schadrach
LQ Newbie
 
Registered: Dec 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Guttorm View Post
Hi

Since there is .asp in the link I guess you get the data from a Windows server. The end of line is different on Windows, so my guess is you need to translate it. There is a command called dos2unix that does this. You might need to install it. On Debian/Ubuntu it's in a package called tofrodos. Then you can use a command like this:

Code:
wget -q -O- http://<IP address>/<filename>.asp?LID=12345 |dos2unix >/dev/ttyS0
That resolved it. I'm confused why a windows machine doing
Code:
wget -q -O- <URL> > COM1:
wouldn't have that problem though. Shouldn't both cases be taking the data from the web server and sending it to the serial port as-is, or am I missing something?

I mean, I get the CRLF vs LF thing, but if I download <URL> from a server and send the output from that to a serial port directly, shouldn't I have gotten the same result regardless of the OS of the client? Or does wget convert newlines to native newlines?

Last edited by Schadrach; 10-05-2010 at 04:01 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add serial port for fedora core 2 jackluli Linux - Software 10 11-26-2009 10:58 AM
expecting Serial port output to a buffer nathan Programming 5 09-22-2009 04:29 PM
[SOLVED] Serial port input/output error john_erlandsson Linux - Newbie 9 07-27-2009 09:47 AM
Extra newlines in my sig? indeliblestamp LQ Suggestions & Feedback 5 08-14-2008 01:33 AM
extra serial port problem... (isa EXP. board) frieza Linux - Hardware 1 02-25-2004 10:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration