On 12/18/12 00:20, Stuart Henderson wrote:
On 2012/12/17 18:26, Andres Perera wrote:
On Mon, Dec 17, 2012 at 6:13 PM, Stuart Henderson <s...@spacehopper.org> wrote:
On 2012-12-17, sven falempin <sven.falem...@gmail.com> wrote:
Hello misc readers,

First, openBSD threads are awesome for debugging.
The trivial topic,
echo -ne "\x00" | nc XXXX port
send a null byte with a GNU echo.

Echo in openbsd does not have -e (and does not warn whan i try it ..)

Noob question:
How to send a null byte over netcat ? am i forced to use perl ?

you can use octal with echo(1) or printf(1).

echo(1) is BSD echo (no backslash sequences)

ksh echo is XSI + BSD

ah, right.

$ echo -n '\000' | hexdump -C
00000000  00                                                |.|
00000001
$ env echo -n '\000' | hexdump -C
00000000  5c 30 30 30                                       |\000|
00000004

in which case printf is probably a better idea.

For scripting, echo is one of the commands I tend to avoid unless I know the data is "safe", because of it's horrific argument parsing.

I've yet to find a way to echo a single '-n' using the sh/ksh builtin. When printing unknown data, I usually end up using 'print -r -- "$var"' (or 'printf "%s" "$var"' if I care about portability).

/Alexander

Reply via email to