REMCTL_OUTPUT(3)
π REMCTL_OUTPUT β the remctl_output(3) page, but make it cute β¨
okay bestie, pull up a chair πͺ because we're about to talk about remctl_output(3) from the remctl Library Reference, and honestly? it's giving results. literally. it retrieves results. i'm obsessed.
β¨ NAME β¨
remctl_output β Retrieve the results of a remctl command π
πΈ SYNOPSIS πΈ
#include <remctl.h>
struct remctl_output *remctl_output(struct remctl *r);
π DESCRIPTION π
so remctl_output() retrieves the next output token from the remote remctl server. iconic behavior, no notes. π«Ά
r is a remctl client object that you made with remctl_new(), and it should have already been used as the argument to remctl_open() and then to either remctl_command() or remctl_commandv(). like, the whole pipeline, bestie. you can't skip steps. π
π¦ the struct π¦
the returned remctl_output struct has these members, and yes we're listing all of them, every single one:
struct remctl_output {
enum remctl_output_type type;
char *data;
size_t length;
int stream; /* 1 == stdout, 2 == stderr */
int status; /* Exit status of remote command. */
int error; /* Remote error code. */
};
and the type field is gonna be one of these four values, periodt:
REMCTL_OUT_OUTPUT
REMCTL_OUT_STATUS
REMCTL_OUT_ERROR
REMCTL_OUT_DONE
π the flow of it all π
a command that the remctl server rejects will return a single output token of type REMCTL_OUT_ERROR. rude, but okay.
a successful command will return zero or more REMCTL_OUT_OUTPUT tokens representing the output of the command, followed by a REMCTL_OUT_STATUS token giving the exit status of the command. the way that works is so clean honestly β¨
so for each command you issue, the caller should call remctl_command() or remctl_commandv() and then call remctl_output() repeatedly to retrieve each output token β until remctl_output() returns a token of type REMCTL_OUT_ERROR or REMCTL_OUT_STATUS. that's your stopping condition. that's the vibe check. π―
π token by token π
- a
REMCTL_OUT_OUTPUTtoken will have data in thedatafield, whose length is given by thelengthfield. the output stream will be given by thestreamfield, with a value of1indicating standard output and a value of2indicating standard error. all other stream values are reserved for future use π so don't go reading meaning into them. - a
REMCTL_OUT_STATUStoken will hold the exit status of the remote command in thestatusfield. following the standard Unix convention, a0status should normally be considered success and any non-zero status should normally be considered failure β although a given command may have its own exit status conventions. (some commands are just built different, iykyk.) - a
REMCTL_OUT_ERRORtoken will have the error message from the server in thedatafield (with length stored inlength) and the protocol error code in theerrorfield. and listen, theerrorcode is the most reliable indicator of the error. the message stored in the error field is free-form text, may or may not be localized, and should not be used for programmatic comparisons. do not do it. i'm serious. π« for the possible error code values and their meanings, see the remctl protocol specification. - if
remctl_output()is called when there is no pending output from the remote server (after aREMCTL_OUT_ERRORorREMCTL_OUT_STATUStoken has already been returned, for example), a token of typeREMCTL_OUT_DONEwill be returned.REMCTL_OUT_DONEtokens do not use any of the other fields of theremctl_outputstruct. they're just there to say "we're done here bestie, go home" π
β οΈ big important one, do not skip this: the returnedremctl_outputstruct must not be freed by the caller. it will be invalidated on any subsequent call to any other remctl API function other thanremctl_error()on the same remctl client object. so the caller should therefore copy out of theremctl_outputstruct any data it wishes to preserve before making any subsequent remctl API calls. copy it or lose it, babe. π
π RETURN VALUE π
remctl_output() returns a pointer to a remctl_output struct on success and NULL on failure. and on failure, the caller should call remctl_error() to retrieve the error message. that's your lifeline, use it. π«Ά
π AUTHOR π
Russ Allbery <eagle@eyrie.org>
π COPYRIGHT AND LICENSE π
Copyright 2007, 2009 The Board of Trustees of the Leland Stanford Junior University
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
SPDX-License-Identifier: FSFAP
π SEE ALSO π
remctl_new(3), remctl_open(3), remctl_command(3), remctl_commandv(3), remctl_error(3)
the current version of the remctl library and complete details of the remctl protocol are available from its web page at <https://www.eyrie.org/~eagle/software/remctl/>.
and that's the whole page, bestie π this was remctl Library Reference version 3.18, dated 2022-05-09 β go forth and retrieve your tokens responsibly, mwah π§β¨
π¦ where this page comes from
- debian bookworm: libremctl-dev 3.18-1+b7 Β· MIT
- debian trixie: libremctl-dev 3.18-3 Β· MIT
- epel 9: remctl-devel 3.18-1.el9 Β· MIT
- ubuntu noble: libremctl-dev 3.18-1.1build2 Β· MIT
- ubuntu questing: libremctl-dev 3.18-3
- ubuntu resolute: libremctl-dev 3.18-5build2 Β· MIT
- ubuntu stonking: libremctl-dev 3.18-5build3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms