#!/usr/bin/env python3
import subprocess

def get_ipv6():
    result = subprocess.run(
        ["ip", "-6", "addr", "show", "scope", "global"],
        capture_output=True,
        text=True
    )
    for line in result.stdout.splitlines():
        if "inet6" in line:
            parts = line.strip().split()
            ip = parts[1].split('/')[0]
            return ip
    return None

def main():
    ip = get_ipv6()
    if ip:
        print(ip)
    else:
        print("No IPv6 address found.")

if __name__ == "__main__":
    main()
