netcat with verbose captures client IP.

but I can not put it in a variable.

VAR=$(nc -v -l 82)

is there a way to get the sender's ip into a $VAR ?


Verbose mode only prints extra lines on the terminal.
it does not place that data into the $VAR


The output is probably going to standard error. Redirect standard error to standard output to capture it:

$ VAR=$( nc -v -l 82 2>&1 )

or, you might want to redirect the original standard output to a file:

$ VAR=$( nc -v -l 82 2>&1 >output )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.