argz - Linux


Overview

argz gathers arguments expressed in the "argz" format and makes them available as a single argument list suitable for use by the execve() family of system calls.

Syntax

argz <options> FILENAME

Options/Flags

  • -d : Set the delimiter for the argument list. By default, the delimiter is a null byte (0x00).
  • -f : Specify the format of the arguments. Can be one of:
    • argv: Arguments separated by spaces, terminated by a null byte.
    • argz: Arguments separated by null bytes, terminated by a double null byte (0x0000).
    • envz: Arguments in the format used by environment variables (name=value pairs), terminated by a null byte.
  • -w : Print the arguments in the specified format. See -f for valid formats.
  • -N: Suppress resolving symbolic links in the argument list.

Examples

Create an argz file:

echo "hello world" | argz -f argz > my_params.argz

Read an argz file:

argz -w argv my_params.argz

Execute a command with an argz argument list:

execve("/bin/cat", NULL, argz -f argv my_params.argz)

Common Issues

  • Argument is not recognized: Ensure that the argument is in the correct format and is not empty.

Integration

argz can be used together with the execve() family of system calls to execute programs with non-standard argument lists. It can also be used with other commands that require arguments in the "argz" format, such as dlopen() and ldd().

Related Commands

  • execve: Executes a program with the specified arguments.
  • dlopen: Loads a dynamic library into memory.
  • ldd: Lists the dynamic dependencies of an executable.