2019年9月22日日曜日
ドキュメント npdb.VNCパスワードの変更
◆VNCパスワードの変更 npdb.py
243 if msgID == "INIT":
244 print "INIT", self.no
245 cmd = "/var/www/html/netpdb/chgPW.sh " + str( self.no + 1 ) + " 00590" + str( self.no + 1 )
246 st = subprocess.call( cmd.split() )
247 return
◆スクリプトchgPW.sh
パラ1 接続番号 1~
パラ2 パスワード(接続ポートの前にゼロが2コ)
1 #!/bin/sh
2
3 uer='/etc/passwd_vnc'
4 pw=koba1234
5 pw=$2
6
7 expect -c "
8 spawn vncpasswd /etc/passwd_vnc$1
9 expect \"Password:\"
10 send \"${pw}\n\"
11 expect \"Verify:\"
12 send \"${pw}\n\"
13 expect "
14
※コマンドを表示される文言ごとに値を入力されたごとくセットするやり方
expect
spawan
send
expect
send
JavaScript キーボードのイベントを取得
プログラム上で、何かキーが入力されたか事を知りたかった!!!
keydownのイベントが広範囲で取得できるので、今回はこれが一番!
addEventListener
キーイベントは、
keydown,keypress,keyup
があります。
ポイント
-----------------------------------------------------------------------------
document.addEventListener('keydown', (event) => {
var keyName = event.key;
console.log(`keydown:${keyName}`);
});
-----------------------------------------------------------------------------
コーディング
---------------------------------------------------------------
<!DOCTYPE html><html> <head>
<script>
document.addEventListener('keydown', (event) => {
var keyName = event.key; console.log(`keydown:${keyName}`); if( keyName=="Shift") console.log("SHT") if( keyName=="Escape") console.log("*ESC") }); </script>
</head> <body> </body></html>
---------------------------------------------------------------結果
---------------------------------------------------------------
new.html?1569104105087:8 keydown:ArrowUp
new.html?1569104105087:8 keydown:ArrowDown
new.html?1569104105087:8 keydown:Shift
new.html?1569104105087:10 SHT
new.html?1569104105087:8 keydown:Escape
new.html?1569104105087:11 *ESC
---------------------------------------------------------------
リンク元
https://techacademy.jp/magazine/19613
ソース
<!DOCTYPE html>
<html>
<head>
<script>
document.addEventListener('keydown', (event) => {
var keyName = event.key;
if (event.ctrlKey) {
console.log(`keydown:Ctrl + ${keyName}`);
} else if (event.shiftKey) {
console.log(`keydown:Shift + ${keyName}`);
} else {
console.log(`keydown:${keyName}`);
}
});
document.addEventListener('keypress', (event) => {
var keyName = event.key;
if (event.ctrlKey) {
console.log(`keypress:Ctrl + ${keyName}`);
} else if (event.shiftKey) {
console.log(`keypress:Shift + ${keyName}`);
} else {
console.log(`keypress:${keyName}`);
}
});
</script>
</head>
<body>
</body>
</html>
結果
new.html?1569103019592:13 keydown:F12
new.html?1569103019592:13 keydown:j
new.html?1569103019592:25 keypress:j
new.html?1569103019592:13 keydown:k
new.html?1569103019592:25 keypress:k
new.html?1569103019592:13 keydown:p
new.html?1569103019592:25 keypress:p
new.html?1569103019592:13 keydown:p
new.html?1569103019592:25 keypress:p
new.html?1569103019592:13 keydown:p
new.html?1569103019592:25 keypress:p
new.html?1569103019592:13 keydown:ArrowUp
new.html?1569103019592:13 keydown:ArrowLeft
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:13 keydown:ArrowUp
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:13 keydown:ArrowLeft
new.html?1569103019592:13 keydown:ArrowUp
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:13 keydown:ArrowLeft
new.html?1569103019592:13 keydown:ArrowUp
4new.html?1569103019592:13 keydown:ArrowLeft
2new.html?1569103019592:11 keydown:Shift + Shift
3new.html?1569103019592:9 keydown:Ctrl + Control
new.html?1569103019592:13 keydown:f
new.html?1569103019592:25 keypress:f
18new.html?1569103019592:9 keydown:Ctrl + Control
new.html?1569103019592:13 keydown:ArrowUp
2new.html?1569103019592:9 keydown:Ctrl + Control
new.html?1569103019592:13 keydown:
new.html?1569103019592:25 keypress:
new.html?1569103019592:13 keydown:ArrowUp
2new.html?1569103019592:13 keydown:ArrowDown
2new.html?1569103019592:13 keydown:ArrowUp
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowLeft
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowLeft
new.html?1569103019592:13 keydown:p
new.html?1569103019592:25 keypress:p
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowLeft
3new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:13 keydown:ArrowUp
new.html?1569103019592:13 keydown:ArrowLeft
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:ArrowDown
new.html?1569103019592:9 keydown:Ctrl + Control
new.html?1569103019592:11 keydown:Shift + Shift
new.html?1569103019592:13 keydown:p
new.html?1569103019592:25 keypress:p
new.html?1569103019592:13 keydown:Tab
new.html?1569103019592:13 keydown:q
new.html?1569103019592:25 keypress:q
new.html?1569103019592:13 keydown:Escape
new.html?1569103019592:13 keydown:v
new.html?1569103019592:25 keypress:v
new.html?1569103019592:13 keydown:b
new.html?1569103019592:25 keypress:b
2new.html?1569103019592:13 keydown:Escape
new.html?1569103019592:13 keydown:Tab
new.html?1569103019592:13 keydown:Escape
2new.html?1569103019592:13 keydown:Tab
2new.html?1569103019592:13 keydown:Alt
new.html?1569103019592:13 keydown:Zenkaku
new.html?1569103019592:13 keydown:NonConvert
new.html?1569103019592:13 keydown:Hiragana
new.html?1569103019592:13 keydown:Convert
2new.html?1569103019592:11 keydown:Shift + Shift
new.html?1569103019592:13 keydown:ArrowUp
new.html?1569103019592:13 keydown:p
new.html?1569103019592:25 keypress:p
new.html?1569103019592:13 keydown:ArrowRight
new.html?1569103019592:13 keydown:Tab
登録:
投稿 (Atom)