TakTuk::Pilot(3)
πΈ NAME πΈ
TakTuk::Pilot β aka TakTuk::Pilot(3), from the User Contributed Perl Documentation, hiiii bestie π β is a Perl module that ease taktuk(1) execution and related I/O management. β¨
π¦ SYNOPSIS π¦
Hereβs the whole vibe in code form, no cap:
use TakTuk::Pilot;
our @line_counter;
sub output_callback(%) {
my %parameters = @_;
my $field = $parameters{fields};
my $rank = $field->{rank};
my $argument = $parameters{argument};
$argument->[$rank] = 1 unless defined($argument->[$rank]);
print "$field->{host}-$rank : ".
"$argument->[$rank] > $field->{line}\n";
$argument->[$rank]++;
}
sub user_input_callback(%) {
my %parameters = @_;
my $taktuk = $parameters{taktuk};
my $descriptor = $parameters{filehandle};
my $buffer;
my $result = sysread($descriptor, $buffer, 1024);
warn "Read error $!" if not defined($result);
# basic parsing, we assume input is buffered on a line basis
chomp($buffer);
if (length($buffer)) {
print "Executing $buffer\n";
$taktuk->send_command("broadcast exec [ $buffer ]");
}
if (not $result) {
print "Terminating\n";
$taktuk->remove_descriptor(type=>'read',
filehandle=>$descriptor);
$taktuk->send_termination();
}
}
die "This script requieres as arguments hostnames to contact\n"
unless scalar(@ARGV);
my $taktuk = TakTuk::Pilot->new();
$taktuk->add_callback(callback=>\&output_callback, stream=>'output',
argument=>\@line_counter,
fields=>['host', 'rank', 'line']);
$taktuk->add_descriptor(type=>'read', filehandle=>\*STDIN,
callback=>\&user_input_callback);
$taktuk->run(command=>"taktuk -s -m ".join(" -m ", @ARGV));
π DESCRIPTION π
The TakTuk::Pilot Perl module makes using TakTuk from inside a Perl program way easier β peep taktuk(1) for the full TakTuk lore. It transparently manages I/O exchanges plus TakTuk data demultiplexing and decoding. Itβs giving βyou do the Perl, Iβll handle the chaos.β π
π CONSTRUCTOR π
π new()
Creates a brand-new TakTuk object, and then you can call all the methods below on it. Slay. β¨
β¨ METHODS β¨
π«Ά add_callback(%)
Adds a callback function tied to some TakTuk output stream on the calling TakTuk object. TakTuk::Pilot calls this callback for each batch of output data coming in from the related stream. The hash you pass as argument may contain these fields:
callbackβ reference to the callback fonction (mandatory)streamβ stream related to this callback, might be'default'(mandatory)fieldsβ reference to an array of fields names relevant to the userargumentβ scalar that should be passed to each callback function call
The callback function should accept a hash as argument. That hash gets populated with these fields:
taktukβ reference to the taktuk object calling this callbackargumentβ scalar given at callback addition orundefstreamβ stream on which output data camefieldsβ reference to a hash containing a fieldname/value pair for each field requested upon callback addition
π«Ά send_command($)
Sends the command passed as argument to the calling TakTuk object. Important: if the TakTuk object is not running, this command gets buffered and executed upon run. π
π«Ά send_termination()
Sends a termination command to the calling TakTuk object. Same energy as send_command: if the TakTuk object is not running, this command will be issued upon run. π
π«Ά run(%)
Runs TakTuk, executing pending commands and waiting for TakTuk output. This function is blocking, bestie: it waits for TakTuk outputs, possibly calls related callback functions, and returns when TakTuk terminates. So all TakTuk commands should be given either before calling run or within a callback function. π¦
This command takes a hash as argument that may contain these fields:
commandβ TakTuk command line to be executedtimeoutβ optional timeout on the wait for TakTuk output
β οΈ Upon occurence of the timeout (if one has been given),runwill returns anETMOUTerror code. Note the in this case TakTuk execution will not be terminated and should be resumed at some point by callingcontinue. π
π«Ά continue()
Resumes a TakTuk execution interrupted by timeout occurence. Iconic little βwe were on a breakβ behavior. π«
π«Ά add_descriptor(%)
Because calling run is blocking while it waits for TakTuk output, it might be interesting to let the TakTuk::Pilot module monitor I/O occurence related to other file descriptors. Thatβs exactly what add_descriptor is for. This function takes a hash as parameter where these fields might be defined:
typeβ'read','write'or'exception'; this is the type of I/O possiblities that should be monitored on the descriptor, as in select system call (mandatory)filehandleβ file descriptor to monitor (mandatory)callbackβ reference to the callback function that should be called when I/O is possible on the file descriptorargumentβ optional scalar value that will be passed with each call to the callback function
The callback function should also accept a hash as an argument, and these fields will be defined in it:
taktukβ reference to theTakTukobject from which the function was calledtypeβ type of I/O occuring (as inadd_callback)filehandleβ the related file descriptor. Notice that the user is in charge of performing the I/O operation itslef (sysreadorsyswrite). Notice also that, because of the use of aselectinTakTuk::Pilot, the use of buffered I/O on this descriptor is strongly discouragedargumentβ the argument that was given toadd_descriptor
π«Ά remove_descriptor(%)
Call this function to remove from the TakTuk object a descriptor previously added with add_descriptor. It takes a hash as argument where these fields may be defined:
typeβ type of I/O (seeadd_descriptor)filehandleβ file descriptor to remove
π«Ά quiet() / verbose()
Change the verbosity of TakTuk::Pilot on STDOUT (default is quiet). Should not be called when TakTuk is running. Respect the boundary, bestie. π«
π«Ά create_session()
Calls setsid in the TakTuk process created by run. The main purpose of this call is to prevent TakTuk from receiving signals sent to the process group to which the pilot belong. Should not be called when TakTuk is running. π
π«Ά pid()
Returns the pid of the process spawned to run TakTuk. Should only be called when TakTuk is running. Donβt ask for the pid when thereβs no process, bestie π
π«Ά error_msg($)
Static function. Returns a character string that corresponds to the error code given as argument. The error code should be one of the values returned by other TakTuk::Pilot functions (add_callback, send_command, send_termination, ...). π§
π ERRORS π
When an error occur in one of these functions, it returns a non nul numeric error code. This code can take one of these values:
TakTuk::Pilot::EARGCMβ Field'command'is missing in a call torun.TakTuk::Pilot::EARGCBβ Field'callback'is missing in a call toadd_callbackoradd_descriptor.TakTuk::Pilot::EARGFHβ Field'filehandle'is missing in a call toadd_descriptororremove_descriptor.TakTuk::Pilot::EARGTPβ Field'type'is missing in a call toadd_descriptororremove_descriptor.TakTuk::Pilot::ETMOUTβ A timeout occured in a call torun.TakTuk::Pilot::ETKTRNβ TakTuk is alredy running butrun,verboseorquiethas been called.TakTuk::Pilot::ETKTNRβ TakTuk is not running butcontinuehas been called.TakTuk::Pilot::ESPIPEβ A call topipefailed inTakTuk::Pilot(the error should be in$!).TakTuk::Pilot::ESFORKβ A call toforkfailed inTakTuk::Pilot(the error should be in$!).TakTuk::Pilot::ESCLOSβ A call toclosefailed inTakTuk::Pilot(the error should be in$!).TakTuk::Pilot::ESELECβ A call toselectfailed inTakTuk::Pilot(the error should be in$!).TakTuk::Pilot::ETPBUGβ Internal bug detected inTakTuk::Pilot.
π SEE ALSO π
tatkuk(1), taktukcomm(3), TakTuk(3)
π AUTHOR π
The original concept of TakTuk has been proposed by Cyrille Martin in his PhD thesis. People involved in this work include Jacques Briat, Olivier Richard, Thierry Gautier and Guillaume Huard.
The author of the version 3 (perl version) and current maintainer of the package is Guillaume Huard. π
π COPYRIGHT π
The TakTuk communication interface library is provided under the terms of the GNU General Public License version 2 or later. π«Ά
Cute sign-off: this page is TakTuk::Pilot(3) from the User Contributed Perl Documentation, served by perl v5.42.3 and dated 1980-01-01. Bye bestie, go pilot some TakTuk π
β¨
π¦ where this page comes from
- nixos 26.05: taktuk 3.7.7
- nixpkgs unstable: taktuk 3.7.8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms