Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Sending Just A Pure Linefeed x0A in Terminal (to telnet)

Hi, does anyone know how to send just a pure LF character (x0A) in Terminal?

I have wrestled with Terminal trying to figure this out but no matter what I do, it will always send an x0D before the x0A. Whether I directly type a Ctrl-J directly, or make my own key mapping in Window Settings specifically sending only x0A, terminal will always add an x0D before the x0A. (I have Telnet debug switched on which returns everything sent in hex, which is how I can tell.)

Any ideas? I've tried the various telnet modes, but the problem appears to be at the Terminal level.

Thanks!

iMac G5 17 2Ghz Rev. B Mac OS X (10.4.2)

iMac 20" Intel Core 2 Duo 2.16Ghz, Mac OS X (10.4.8)

Posted on Feb 14, 2007 10:54 PM

Reply
6 replies

Feb 15, 2007 9:24 AM in response to Anthony Milas

I fear I might not understand your problem, but...

Usually, hitting ctrl-J sends a LF to the process reading the other end of the tty (e.g., the shell). But the tty usually echo back CR+NL to you (i.e., to Terminal.app). If this is your problem, then try

<pre>stty -onlcr</pre>
If your terminal is messed up, then reset by

<pre>stty onlcr</pre>

PowerMacG4, PowerBookG4, iMac(C2D) Mac OS X (10.4.8)

Feb 15, 2007 3:39 PM in response to Anthony Milas

I interpret your request as you want to send a linefeed character to your telnet session, therefore Nils's echo solution probably won't help you and playing with stty settings will probably break other things. I can't imagine why you want to do such a thing, but with the "expect" utility you can script a telnet session and send any character you want without shells or stty settings messing it up.

There's an example on an expect script at:

http://discussions.apple.com/message.jspa?messageID=4015275

Feb 15, 2007 5:41 PM in response to Ken Nellis

Hi All, thanks for your responses!

I think I wasn't clear enough in my original post. Also, I have since discovered through my own experimentation, which was further confirmed by trying that stty suggestion, that it is NOT terminal causing the problem but is in fact Telnet.

Eg, if I "stty -onlcr", my Terminal window no longer prints a <CR> when I press return, it just does linefeeds. Which is great - thats what I wanted (albeit looking somewhat messy I know!). When I go into Telnet, this remains the same. However, the moment I actually send a string to a host through Telnet, Telnet converts the <LF>'s into <CR><LF>'s. And it does this both ways. I can see from the hexdump (in telnet this is "toggle netdata") that the host sends me a single <LF>, yet telnet displays a <CR><LF> (yes, Telnet overrides my Terminal setting!). And vice versa - I know because I have configured my Terminal window to only send <LF>, that Telnet is the culprit as my hexdump shows me what was sent to the host when I pressed return, was <CR><LF>.

Now, here is the situation I am actually in: I am trying to perform low-level testing on a host which is not normally accessed via a Telnet session by a human operator. It is normally accessed through a complex interface via software.

The host IS however text-based, and in principle I should be able to conduct low-level testing this way (and this would be extremely useful). The only problem is that the host requires a "<LF>" as the end-of-command-string delimiter. If the host is sent a command ending with a "<CR><LF>", then the host sees the sent command as corrupt. The "<CR>" added by Telnet is part of the command string from the point of view of the host, and this renders the command invalid.

So, I can now only think of a few possible solutions:

1) Using a different Telnet program, that allows me to configure it to send just a <LF>. I have not found any alternative Telnet programs for OS X, excepting for a piece of terminal-emulation software called dataComet which unfortunately is very old and appears to not recognise my host as a valid thing to connect to.

2) Compiling another version of the existing Telnet program, with the ability to send, and display pure <LF>'s.

3) Discovering a hidden "configuration file" for Telnet that can allow me to set an option for pure <LF>'s to be sent.

4) Finding whomever it was who decided that Telnet should override the Terminal settings by default and provide no way to switch off this "feature", and throttling them. 😉

Okay, the last one isn't a solution, but it might bring some temporary relief.

So can anyone help me with any of the above options? Please bear in mind that in the case of option 2, I have never compiled anything via the command line, and have little experience with C.

Thanks!

Feb 15, 2007 6:18 PM in response to Ken Nellis

The "set" command also looks interesting.

telnet> help set
set operating parameters ('set ?' for more)
telnet> set ?
echo character to toggle local echoing on/off
escape character to escape back to telnet command mode
rlogin rlogin escape character
tracefile file to write trace information to

The following need 'localchars' to be toggled true
flushoutput character to cause an Abort Output
interrupt character to cause an Interrupt Process
quit character to cause an Abort process
eof character to cause an EOF

The following are for local editing in linemode
erase character to use to erase a character
kill character to use to erase a line
lnext character to use for literal next
susp character to cause a Suspend Process
reprint character to use for line reprint
worderase character to use to erase a word
start character to use for XON
stop character to use for XOFF
forw1 alternate end of line character
forw2 alternate end of line character
ayt alternate AYT character

autoflush enable flushing of output when sending interrupt characters
autosynch enable automatic sending of interrupt characters in urgent mode
autologin enable automatic sending of login and/or authentication info
authdebug enable Toggle authentication debugging
autoencrypt enable automatic encryption of data stream
autodecrypt enable automatic decryption of data stream
verbose_encrypt enable Toggle verbose encryption output
encdebug enable Toggle encryption debugging
skiprc enable don't read ~/.telnetrc file
binary enable sending and receiving of binary data
inbinary enable receiving of binary data
outbinary enable sending of binary data
crlf enable sending carriage returns as telnet <CR><LF>
crmod enable mapping of received carriage returns
localchars enable local recognition of certain control characters

debug enable debugging
netdata enable printing of hexadecimal network data (debugging)
prettydump enable output of "netdata" to user readable format (debugging)
options enable viewing of options processing (debugging)
termdata enable (debugging) toggle printing of hexadecimal terminal data
? display help information
telnet>

Sending Just A Pure Linefeed x0A in Terminal (to telnet)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.