Mender-cli subprocess login works on Linux but fails on Windows – workaround?

I’m trying to send data to a remote device using mender-cli. It works fine on Linux, but I’m running into issues on Windows since mender-cli isn’t officially available there. Is there any workaround or alternative method to get it working on a Windows system?

Here’s the relevant part of my code:

result = subprocess.run(
    login_cmd,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    text=True,
    check=True
)

The login_cmd I’m passing looks like this:

['mender-cli', 'login', '--server', 'https://eu.hosted.mender.io/', '--username', 'a.gl@gmai.com', '--password', 'ABC']

This works perfectly on Debian Linux, but fails on Windows.
How can I get this working on a Windows system?

Hi @aakash_goyal,

The only somewhat promising approach on Windows is probably using the WSL (Windows Subsystem for Linux).

Alternatively you can of course look at the source code (GitHub - mendersoftware/mender-cli: A general-purpose CLI for the Mender backend) and try to either adapt it or extract the relevant parts, or even skip mender-cli entirely. In the end, it is just a convenience tool for interacting with the API (Mender API docs), so it might be a viable solution to just use the API directly in your script.

Greetz,
Josef