UPSCLI_SENDLINE(3)

πŸ’– UPSCLI_SENDLINE(3) β€” the NUT Manual, bestie edition πŸ’–

okay so welcome to UPSCLI_SENDLINE(3), part of the NUT Manual ✨ this is the one about yeeting a single command at your UPS. sit down, grab a snack πŸ“, we're doing this.


🌸 NAME 🌸

upscli_sendline, upscli_sendline_timeout, upscli_sendline_timeout_may_disconnect β€” send a single command to a UPS πŸ’…


✨ SYNOPSIS ✨

#include <upsclient.h>
#include <time.h> /* or <sys/time.h> on some platforms */

int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen);

int upscli_sendline_timeout(UPSCONN_t *ups, const char *buf, size_t buflen,
        const time_t timeout);

int upscli_sendline_timeout_may_disconnect(UPSCONN_t *ups,
        const char *buf, size_t buflen, const time_t timeout,
        int may_disconnect);
note the little header situation: <time.h> is the vibe, but some platforms want <sys/time.h> instead. iykyk 😌

πŸ¦‹ DESCRIPTION πŸ¦‹

so upscli_sendline() and upscli_sendline_timeout() take a pointer ups to a UPSCONN_t state structure, and they transmit a buffer buf of size buflen over to the server. that's it, that's the whole job 🫢

and like… the data in buf has to be a fully formatted protocol command, because literally no parsing of the buffer happens inside these functions. zero. none. you hand it a whole command or you hand it nothing, bestie 😭

now here's the tea on the three of them β˜• the difference is all about timeouts and disconnecting:

  • upscli_sendline_timeout() lets the caller decide the amount of time β€” timeout seconds β€” after which it should give up and return. main character energy, you're in charge πŸ‘‘
  • upscli_sendline() does not offer this freedom, and uses an immediate timeout (0 second). no negotiation πŸ’€
  • both of those disconnect upon errors. no cap. πŸ™ˆ
  • upscli_sendline_timeout_may_disconnect() further allows you to enable or disable such disconnections, thanks to may_disconnect. your call, your rules ✨

πŸ’€ RETURN VALUE πŸ’€

upscli_sendline() and upscli_sendline_timeout() return 0 on success, or -1 if an error occurs. that's the whole vibe check: 0 slay, -1 not slay πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page!! 🌈 this was Network UPS Tools 2.8.5, dated 10/07/2026, filed under UPSCLI_SENDLINE(3) in the NUT Manual. go forth and send your lines, you absolute icon πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from