The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Quiq::Ssh - Führe Kommando per SSH aus

BASE CLASS

Quiq::Hash

DESCRIPTION

Ein Objekt der Klasse repräsentiert eine SSH-Verbindung zu einem Host. Über die Verbindung können Shell-Kommandos ausgeführt werden. Die Klasse ist ein Wrapper fr die Klasse Net::SSH::Perl, die das SSH Netzprotokoll direkt spricht.

EXAMPLE

Zeige Inhalt des Homeverzeichnisses auf Host dssp an:

    $ perl -MQuiq::Ssh -E 'print Quiq::Ssh->new("dssp")->exec("ls")'

METHODS

Klassenmethoden

new() - Konstruktor

Synopsis

    $ssh = $class->new($host,@opt);

Arguments

$host

Hostname

Options

-debug => $bool (Default: 0)

Schreibe Debug-Information über die SSH-Kommunikation nach STDERR.

-loginShell => $bool (Default: 1)

Default für Methode exec(): Führe Kommandos per Login-Shell aus.

-user => $user (Default: Wert von $USER)

Name des Benutzers.

Returns

Objekt

Description

Instantiiere ein Objekt für die Ausführung von Kommandos via SSH auf Host $host über den Benutzer $user.

Objektmethoden

exec() - Führe Kommando aus

Synopsis

    ($stdout,$stderr) = $ssh->exec($cmd,@opt);
    ($stdout,$stderr,$exit) = $ssh->exec($cmd,-sloppy=>1,@opt);

Arguments

$cmd (String)

Kommandozeile

Options

-loginShell => $bool (Default: Wert der Option beim Konstruktor)

Führe das Remote-Kommando unter einer Login-Shell aus. Als Shell wird die bash verwendet.

-sloppy => $bool (Default: 0)

Wirf keine Exception, wenn das Remote-Kommando fehlschlägt, sondern liefere den Exitcode als dritten Returnwert zurück.

Returns

$stdout

Ausgabe des Kommandos auf stdout (String).

$stderr

Ausgabe des Kommandos auf stderr (String).

$exit

Exitcode des Kommandos (Integer). Wird gesetzt, wenn -sloppy=>1 ist, sonst konstant 0.

VERSION

1.145

AUTHOR

Frank Seitz, http://fseitz.de/

COPYRIGHT

Copyright (C) 2019 Frank Seitz

LICENSE

This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.