mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +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.
|
||||
Also all returned lines are terminated with \r\n.
|
||||
Example:<br>
|
||||
<ul>
|
||||
<code>
|
||||
attr tPort password secret<br>
|
||||
attr tPort password {use FritzBoxUtils;;FB_checkPw("localhost","$password") }<br>
|
||||
</code>
|
||||
or if you defined multiple users on the Fritzbox:<br>
|
||||
<code>
|
||||
attr tPort password {use FritzBoxUtils;;FB_checkPw("localhost","$user", "$password") }<br>
|
||||
attr tPort password {"$password" eq "secret"}
|
||||
</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>
|
||||
|
||||
<a name="globalpassword"></a>
|
||||
|
@ -178,7 +178,7 @@ telnet) or single client command (via fhem.pl). Example:
|
||||
</ul>
|
||||
or
|
||||
<ul>
|
||||
<code>fhem.pl <fhemhost>:7072 "<command>..."</code>
|
||||
<code>fhem.pl <fhemhost>:7072 "<fhem-command>" "..."</code>
|
||||
</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
|
||||
if(int(@ARGV) != 1 && int(@ARGV) != 2) {
|
||||
if(int(@ARGV) < 1) {
|
||||
print "Usage:\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);
|
||||
exit(1);
|
||||
}
|
||||
@ -324,15 +324,20 @@ if($^O !~ m/Win/ && $< == 0) {
|
||||
|
||||
###################################################
|
||||
# Client code
|
||||
if(int(@ARGV) == 2) {
|
||||
if(int(@ARGV) > 1) {
|
||||
my $buf;
|
||||
my $addr = $ARGV[0];
|
||||
$addr = "localhost:$addr" if($ARGV[0] !~ m/:/);
|
||||
my $addr = shift @ARGV;
|
||||
$addr = "localhost:$addr" if($addr !~ m/:/);
|
||||
my $client = IO::Socket::INET->new(PeerAddr => $addr);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
exit(0);
|
||||
@ -576,6 +581,8 @@ sub
|
||||
Log3($$$)
|
||||
{
|
||||
my ($dev, $loglevel, $text) = @_;
|
||||
|
||||
$dev = $dev->{NAME} if(defined($dev) && ref($dev) eq "HASH");
|
||||
|
||||
if(defined($dev) &&
|
||||
defined($attr{$dev}) &&
|
||||
|
Loading…
Reference in New Issue
Block a user