Re: nc -N and EOF

2018-03-06 Thread Patrick Welche
On Wed, Feb 28, 2018 at 11:09:57PM +, Valery Ushakov wrote:
> Patrick Welche  wrote:
> 
> > I tried
> > 
> >   echo "hello from server" | nc -l 1234
> > 
> >   nc -l 1234 << EOF
> >   hello from server
> >   EOF
> > 
> >   echo "hello from server" > tmpfile
> >   nc -l 1234 < tmpfile
> > 
> > and in all cases
> > 
> >   nc  -N 127.0.0.1 1234
> > 
> > prints "hello from server" but doesn't exit.
> 
> Use
> 
>   nc -d localhost 1234

Thank you!

  echo "hello from server" | nc -l 1234

  nc -N -d localhost 1234

Patrick


Re: nc -N and EOF

2018-02-28 Thread Valery Ushakov
Patrick Welche  wrote:

> I tried
> 
>   echo "hello from server" | nc -l 1234
> 
>   nc -l 1234 << EOF
>   hello from server
>   EOF
> 
>   echo "hello from server" > tmpfile
>   nc -l 1234 < tmpfile
> 
> and in all cases
> 
>   nc  -N 127.0.0.1 1234
> 
> prints "hello from server" but doesn't exit.

Use

  nc -d localhost 1234

-uwe



Re: nc -N and EOF

2018-02-28 Thread Patrick Welche
On Tue, Feb 27, 2018 at 09:50:34PM -0500, Eric Hawicz wrote:
> On 2018-02-27 10:33 AM, Patrick Welche wrote:
> >echo "hello from server" | nc -l 1234
> > 
> >nc -l 1234 << EOF
> >hello from server
> >EOF
> > 
> >echo "hello from server" > tmpfile
> >nc -l 1234 < tmpfile
> > 
> > and in all cases
> > 
> >nc  -N 127.0.0.1 1234
> > 
> > prints "hello from server" but doesn't exit. Maybe I'm misunderstanding
> > 
> >   -N  shutdown(2) the network socket after EOF on the input.  Some
> >   servers require this to finish their work.
> > 
> > ?
> Do you hit control-D on the client nc to give it the EOF on the input?

I was hoping to be able to script both sides, and have the file go from
the listener to the client rather than the other way around.

Patrick


Re: nc -N and EOF

2018-02-27 Thread Eric Hawicz

On 2018-02-27 10:33 AM, Patrick Welche wrote:

   echo "hello from server" | nc -l 1234

   nc -l 1234 << EOF
   hello from server
   EOF

   echo "hello from server" > tmpfile
   nc -l 1234 < tmpfile

and in all cases

   nc  -N 127.0.0.1 1234

prints "hello from server" but doesn't exit. Maybe I'm misunderstanding

  -N  shutdown(2) the network socket after EOF on the input.  Some
  servers require this to finish their work.

?

Do you hit control-D on the client nc to give it the EOF on the input?