Switch Socket on with sispmctl -o 1, off with sispmctl -f 1 and get status with sispmctl -m all
To have premission for a webserver to execute the command:
/etc/udev/rules.d/90-local.rules:
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", \Because sometimes a wrong status came back i read it twice and compare it
ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="fd13", \
GROUP="www-data", MODE="0660"
<?php
function sispm_status() {
$pins1=array(0=>'0'); $pins2=array(0=>'1');
while ($pins1 !== $pins2) {
unset($pins1);
unset($pins2);
exec("/usr/bin/sispmctl -qnm all", $pins1);
exec("/usr/bin/sispmctl -qnm all", $pins2);
}
return $pins1;
}
$pins = sispm_status();
if (isset($_POST['update']))
for ($i = 0; $i <= 3; $i++)
if (isset($_POST["pin$i"])) {
if (!$pins[$i]) exec("/usr/bin/sispmctl -qno ".($i+1)); }
else if ($pins[$i]) exec("/usr/bin/sispmctl -qnf ".($i+1));
$pins = sispm_status();
?>
<html>
<body>
<form method="post">
<input type="checkbox" name="pin0" value="1" <?= ($pins[0]?'checked':'') ?>> Socket 1<br>
<input type="checkbox" name="pin1" value="1" <?= ($pins[1]?'checked':'') ?>> Socket 2<br>
<input type="checkbox" name="pin2" value="1" <?= ($pins[2]?'checked':'') ?>> Socket 3<br>
<input type="checkbox" name="pin3" value="1" <?= ($pins[3]?'checked':'') ?>> Socket 4<br>
<input type="submit" name="update">
</form>
</body>
</html>
perl:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi = CGI->new();
my @ports=("PC","Printer","-","-");
print "Content-type: text/html\n";
print "\n";
print "<HTML><HEAD><TITLE>USB Steckdosenleiste</TITLE><META http-equiv=\"refresh\" content=\"60;steckdose.cgi\"></HEAD>\n\n";
print "<BODY>\n";
for my $port ($cgi->param()) {
if ($cgi->param($port) eq "on") { system "/usr/bin/sispmctl -q -o $port"; }
elsif ($cgi->param($port) eq "off") { system "/usr/bin/sispmctl -q -f $port"; }
}
print "<H1>USB Steckdosenleiste</H1><UL>\n";
my @states = `/usr/bin/sispmctl -q -g all`;
my $cnt = 1;
for my $state (@states) {
if ($ports[$cnt-1] ne "-") {
if ($state eq "off\n") { print "<LI>".$ports[$cnt-1]." ist ausgeschaltet [<A href=\"steckdose.cgi?$cnt=on\">einschalten</A>]\n"; }
else { print "<LI>".$ports[$cnt-1]." ist eingeschaltet [<A href=\"steckdose.cgi?$cnt=off\">ausschalten</A>]\n"; }
}
$cnt++;
}
print "</UL>\n";
print "</BODY></HTML>"
[ view entry ] ( 1475 views ) | print article
$ sudo apt-get install build-essential fakeroot dpkg-dev
$ mkdir build
$ cd build
$ sudo apt-get source foo
$ sudo apt-get build-dep foo
$ cd foo
$ dpkg-buildpackage -rfakeroot -b -us -uc -nc
-nc does not clean, usefull if you change something and rebuild
http://www.cyberciti.biz/faq/rebuilding ... y-package/
[ view entry ] ( 1223 views ) | print article
find -name 'Pic*' -exec sh -c 'mv $1 "$(echo $1 | sed s/\\./_/g | sed s/^_/\\./g | sed s/_-//g)"' {} {} \;
[ view entry ] ( 921 views ) | print article
atomic.h Read More...
[ view entry ] ( 972 views ) | print article
for i in $(seq 2 254); do ping -c 1 192.168.0.$i | grep -q rtt && echo "found 192.168.0.$i"; done
[ view entry ] ( 783 views ) | print article
<<First <Back | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Next> Last>>