2

I want to test mail relay. It requires me to send CRLF at the end of DATA.

I can use toggle CRLFin telnet, or -C option for NC. But is there a way to input CRLF from keyboard in linux terminal?

Greg Askew
  • 34,339
  • 3
  • 52
  • 81
George Shuklin
  • 226
  • 2
  • 7

2 Answers2

1

Using vi, create a file having these two characters

  • vi file then i to enter input mode
  • Hit ^V followed by the decimal code of ^M:
  • ^V013 for CR
  • then save :wq since LF is automatically added by vi

If you have it (or install it) doing

hexdump -C file

should show

00000000  0d 0a                                             |..|

Now you can copy / paste or cat that file where necessary.

You could also prepare the file with other characters, headers that you cat one shot to your application.

Another, way is to install dos2unix (depending on your distrib), then prepare the file as necessary (ie without the CR aka ^M), then do

unix2dos file

and all 0a will be converted to 0d0a

Déjà vu
  • 5,408
  • 9
  • 32
  • 52
0

Normally I would expect you can just press enter/return but if you really need to send CRLF then you can use

Ctrlm for CR and
Ctrlj for LF

user9517
  • 114,104
  • 20
  • 206
  • 289
  • Unfortunately Ctrl-J produces same result as Ctrl-M. You can check it with command `cat |hexdump` and pressing ctrl-m ctrl-j ctrl-d. Output is 0000000 0a0a. – George Shuklin Jan 31 '17 at 18:07
  • i think your testing method is flawed. – user9517 Jan 31 '17 at 18:13
  • If my method is flawed, where and how? I hexdumped output of cat (which in turn receives it from keyboard input). Do you know better way to see what has been inputed? – George Shuklin Feb 02 '17 at 09:46