UPSCLI_READLINE(3)
β¨ UPSCLI_READLINE β bestie, let's read ONE line from the UPS π
okay so this is the UPSCLI_READLINE(3) page from the NUT Manual, and it's literally just three little functions that grab a single response line from a UPS. no cap. let's get into it π¦
πΈ NAME πΈ
upscli_readline, upscli_readline_timeout, upscli_readline_timeout_may_disconnect β Read a single response from a UPS β¨
π SYNOPSIS π
#include <upsclient.h>
#include <time.h> /* or <sys/time.h> on some platforms */
int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen);
int upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen,
const time_t timeout);
int upscli_readline_timeout_may_disconnect(UPSCONN_t *ups,
char *buf, size_t buflen, const time_t timeout,
int may_disconnect);
psst β that<time.h>include is like,<sys/time.h>on some platforms instead, iykyk π
π DESCRIPTION π
so. the way that upscli_readline() and upscli_readline_timeout() work is: you hand them ups, which is a pointer to a UPSCONN_t state structure, they receive a single line from the server, and then they copy up to buflen bytes of that response into the buffer buf. that's the whole vibe. π«Ά
and not me mentioning this β some parsing happens while it's receiving, okay?? specifically, ERR messages from upsd(8) get detected, and when that happens this function will return -1. so watch out bestie π
now the difference between the three, because this is the part everyone asks about:
upscli_readline_timeout()β lets you (the caller) decide the amount of time (timeoutseconds) after which it should give up and return. so much freedom, we love that for you πupscli_readline()β does not offer this freedom, and just uses the NUT default network timeout, which is5 seconds. she's set in her ways fr fr π- both of those two disconnect upon errors. yes, literally, they will hang up on you.
upscli_readline_timeout_may_disconnect()β goes further and lets you enable or disable such disconnections with themay_disconnectargument. iconic behaviour, honestly β¨
π RETURN VALUE π
upscli_readline() and upscli_readline_timeout() return 0 on success π, or -1 if an error occurs π.
π¦ SEE ALSO π¦
upscli_fd(3)upscli_get(3)upscli_readline(3)upscli_sendline(3)upscli_ssl(3)upscli_strerror(3)upscli_upserror(3)
and that's the whole page, bestie, you ate π
this was Network UPS Tools version 2.8.5, dated 10/07/2026 β go forth and read those lines, main character ππ π
π¦ where this page comes from
- fedora 43: nut-devel 2.8.5-9.fc43 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 43: nut-devel 2.8.5-9.fc43 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 44: nut-devel 2.8.5-9.fc44 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 44: nut-devel 2.8.5-9.fc44 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms