run#

pync.run(args, stdin=None, stdout=None, stderr=None, input=None, capture_output=False, Netcat=<class 'pync.netcat.Netcat'>)[source]#

Create and run a Netcat instance. This is similar to running pync from the command-line.

Parameters:
  • args (str) – A string containing command-line arguments.

  • stdin (file, optional) – A file-like object to read outgoing network data from.

  • stdout (file, optional) – A file-like object to write incoming network data to.

  • stderr (file, optional) – A file-like object to write error/verbose/debug messages to.

Returns:

Error status code depending on success (0) or failure (>0).

Return type:

int

Examples:

Create a local TCP server on port 8000.#
import pync
pync.run('-l localhost 8000')
Connect to a local TCP server on port 8000.#
import pync
pync.run('localhost 8000')
Create a local TCP server to host a file on port 8000.#
import pync
with open('file.in', 'rb') as f:
    pync.run('-l localhost 8000', stdin=f)
Connect to a local TCP server to download a file on port 8000.#
import pync
with open('file.out', 'wb') as f:
    pync.run('localhost 8000', stdout=f)