mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-30 18:12:28 +00:00
fhem.pl client mode: password support
git-svn-id: https://svn.fhem.de/fhem/trunk@3734 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
923bbefb24
commit
3a5fbcde09
@ -383,14 +383,17 @@ telnet_ActivateInform($)
|
|||||||
IAC requests to supress echo while entering the password.
|
IAC requests to supress echo while entering the password.
|
||||||
Also all returned lines are terminated with \r\n.
|
Also all returned lines are terminated with \r\n.
|
||||||
Example:<br>
|
Example:<br>
|
||||||
|
<ul>
|
||||||
<code>
|
<code>
|
||||||
attr tPort password secret<br>
|
attr tPort password secret<br>
|
||||||
attr tPort password {use FritzBoxUtils;;FB_checkPw("localhost","$password") }<br>
|
attr tPort password {"$password" eq "secret"}
|
||||||
</code>
|
|
||||||
or if you defined multiple users on the Fritzbox:<br>
|
|
||||||
<code>
|
|
||||||
attr tPort password {use FritzBoxUtils;;FB_checkPw("localhost","$user", "$password") }<br>
|
|
||||||
</code>
|
</code>
|
||||||
|
</ul>
|
||||||
|
Note: if this attribute is set, you have to specify a password as the
|
||||||
|
first argument when using fhem.pl in client mode:
|
||||||
|
<ul>
|
||||||
|
perl fhem.pl localhost:7072 secret "set lamp on"
|
||||||
|
</ul>
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<a name="globalpassword"></a>
|
<a name="globalpassword"></a>
|
||||||
|
@ -178,7 +178,7 @@ telnet) or single client command (via fhem.pl). Example:
|
|||||||
</ul>
|
</ul>
|
||||||
or
|
or
|
||||||
<ul>
|
<ul>
|
||||||
<code>fhem.pl <fhemhost>:7072 "<command>..."</code>
|
<code>fhem.pl <fhemhost>:7072 "<fhem-command>" "..."</code>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
19
fhem/fhem.pl
19
fhem/fhem.pl
@ -286,10 +286,10 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
|||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# Start the program
|
# Start the program
|
||||||
if(int(@ARGV) != 1 && int(@ARGV) != 2) {
|
if(int(@ARGV) < 1) {
|
||||||
print "Usage:\n";
|
print "Usage:\n";
|
||||||
print "as server: fhem configfile\n";
|
print "as server: fhem configfile\n";
|
||||||
print "as client: fhem [host:]port cmd\n";
|
print "as client: fhem [host:]port cmd cmd cmd...\n";
|
||||||
CommandHelp(undef, undef);
|
CommandHelp(undef, undef);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -324,15 +324,20 @@ if($^O !~ m/Win/ && $< == 0) {
|
|||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# Client code
|
# Client code
|
||||||
if(int(@ARGV) == 2) {
|
if(int(@ARGV) > 1) {
|
||||||
my $buf;
|
my $buf;
|
||||||
my $addr = $ARGV[0];
|
my $addr = shift @ARGV;
|
||||||
$addr = "localhost:$addr" if($ARGV[0] !~ m/:/);
|
$addr = "localhost:$addr" if($addr !~ m/:/);
|
||||||
my $client = IO::Socket::INET->new(PeerAddr => $addr);
|
my $client = IO::Socket::INET->new(PeerAddr => $addr);
|
||||||
die "Can't connect to $addr\n" if(!$client);
|
die "Can't connect to $addr\n" if(!$client);
|
||||||
syswrite($client, "$ARGV[1] ; quit\n");
|
for(my $i=0; $i < int(@ARGV); $i++) {
|
||||||
|
syswrite($client, $ARGV[$i]."\n");
|
||||||
|
}
|
||||||
shutdown($client, 1);
|
shutdown($client, 1);
|
||||||
while(sysread($client, $buf, 256) > 0) {
|
while(sysread($client, $buf, 256) > 0) {
|
||||||
|
$buf =~ s/\xff\xfb\x01Password: //;
|
||||||
|
$buf =~ s/\xff\xfc\x01\r\n//;
|
||||||
|
$buf =~ s/\xff\xfd\x00//;
|
||||||
print($buf);
|
print($buf);
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -576,6 +581,8 @@ sub
|
|||||||
Log3($$$)
|
Log3($$$)
|
||||||
{
|
{
|
||||||
my ($dev, $loglevel, $text) = @_;
|
my ($dev, $loglevel, $text) = @_;
|
||||||
|
|
||||||
|
$dev = $dev->{NAME} if(defined($dev) && ref($dev) eq "HASH");
|
||||||
|
|
||||||
if(defined($dev) &&
|
if(defined($dev) &&
|
||||||
defined($attr{$dev}) &&
|
defined($attr{$dev}) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user