FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: Simon74 am 29 November 2015, 08:21:37

Titel: Perl Syntax 99_myUtils.pm: (Can't use string ... as an ARRAY ref while)
Beitrag von: Simon74 am 29 November 2015, 08:21:37
Hallo,

die Sub ShutdownWindows funktioniert, beim Aufruf von ShutdownLinux bekomme ich jedoch folgende Meldung:
Can't use string ("my-pc2") as an ARRAY ref while "strict refs" in use at ./FHEM/99_myUtils.pm line

Meine Subs:
###############################################################################
# Shutdown Windows-PC
###############################################################################
sub ShutdownWindows
{
my $pc = $_[0];
`net rpc shutdown -C \"Shutdown durch FHEM\" -S $pc -U DOMAIN/Backup%Password -f -t 5`;
}

###############################################################################
# Shutdown Linux-PC
###############################################################################
sub ShutdownLinux
{
my $pc = $_[0];
`ssh -tt ausschalten@$pc 'sudo shutdown -h now'`;
}


Der Aufruf aus dem WOL Modul erfolgt so:
shutdownCmd {ShutdownLinux("my-pc2")}

Titel: Antw:Perl Syntax 99_myUtils.pm: (Can't use string ... as an ARRAY ref while)
Beitrag von: Icinger am 29 November 2015, 08:23:53
Lass einfach das [ 0 ] weg......

Und das `net rpc shutdown -C \"Shutdown durch FHEM\" -S $pc -U DOMAIN/Backup%Password -f -t 5`; musst als system-Befehl aufrufen

also system("net rpc shutdown -C \"Shutdown durch FHEM\" -S $pc -U DOMAIN/Backup%Password -f -t 5");
Titel: Antw:Perl Syntax 99_myUtils.pm: (Can't use string ... as an ARRAY ref while)
Beitrag von: Simon74 am 29 November 2015, 19:19:09
Danke