• Dialog cannot open tty-output


    dialog บน Oracle Enterprise Linux และ Ubuntu ไม่เหมือนกัน (ทำไมล่ะ…ไม่ทราบครับ) สร้างสคริปต์ชื่อ file.sh มีข้อความว่า #!/bin/bash FILE=$(dialog –ascii-lines –title “Delete a file” –stdout \ –title “Please choose a file to delete” –fselect /tmp/ 14 48) echo $FILE บน Ubuntu รันได้ผลลัพธ์ แต่บน Oracle Enterprise Linux ต้องเปลี่ยนสคริปต์มีสองแบบ แบบแรก #!/bin/sh dialog –ascii-lines –title “Delete a file” –stdout \ –title “Please choose…

    >> Read More <<

  • ชีวิตสะดวกและปลอดภัยด้วยการ Sign In บน Google Chrome


    เคยเจอปัญหาเหล่านี้เมื่อต้องไปใช้งานเครื่องอื่นที่ไม่ใช่เครื่องตนเองหรือไม่ ? จะเข้าเว็บไซต์ที่เคย Bookmark เอาไว้ในเครื่องตนเอง ก็ทำไม่ได้ ทำไงดีรหัสผ่านมากมาย เคยให้เว็บจำไว้ให้ แล้วตอนนี้จะใช้งานยังไงหล่ะ สภาพแวดล้อมไม่คุ้นชินเมื่อไปใช้เครื่องอื่น ปัญหาเหล่านี้จะหมดไป เมื่อใช้ Google Chrome และ ทำการ Sign In เอาไว้ คำเตือน: ผู้ที่จะใช้วิธีการนี้ ควรทำระบบ 2-Step Verification ไว้ก่อน เพื่อป้องกันรหัสผ่านรั่วไหล และป้องกัน กรณีมี Keyboard Logger ฝังตัวเพื่อดักการพิมพ์รหัสผ่านจาก Keyboard ซึ่งแม้จะมีผู้ร้ายดักรหัสผ่านไปได้ ก็จะติดขั้นตอนการยืนยันตัวตนอีกชั้นของ 2-Step Verification กรณีผู้ใช้ Google Apps ขององค์กร (ทั้ง For Education และ For Business) ระบบจะทำการสร้าง Profile แยกให้ แต่ถ้าเป็น Google Account ของ Gmail นั้น…

    >> Read More <<

  • Spam 20150508


    นี่คือจดหมายหลอกลวง อย่าหลงเชื่อ ห้ามคลิก หรือ Reply ให้ลบทิ้งทันที

    >> Read More <<

  • เริ่มต้นใช้งาน GAS Editor


    เปิด https://drive.google.com แล้ว Login คลิกปุ่ม New > Google Sheets ตั้งชื่อไฟล์: GASWS1 เมนู Tools > Script Editor เลือก Blank Project ตั้งชื่อโปรเจค : myproject1 เมนู File > New > Script File ตั้งชื่อ: myscript1 แก้ไข myFunction() ตามนี้ function myFunction() { Logger.log(“Hello World”); } เมนู File > Save หรือ กดปุ่ม Ctrl+s เมนู Run > myFunction ดูผลได้ที่ เมนู View >…

    >> Read More <<

  • Case Study: ตรวจสอบ Website Availability ด้วย Google Apps Script


    เปิด Google Sheets : GASWS1 สร้าง Sheet ใหม่ ชื่อ “Log” เมนู Tools > Script Editor… เมนู File > New > Script File ตั้งชื่อ: myscript4 เขียนโค๊ดตามนี้  function check_website(url) { var response = UrlFetchApp.fetch(url, {muteHttpExceptions: true}); return response.getResponseCode(); } function doLog(timestamp, responseCode, timeDiff) { var ss=SpreadsheetApp.getActiveSpreadsheet(); var sheet=SpreadsheetApp.setActiveSheet(ss.getSheetByName(“Log”)); sheet.appendRow([timestamp, responseCode, timeDiff]); } function getTime() { var startTime…

    >> Read More <<

  • อ่าน/เขียนข้อมูลกับ Google Sheets


    เปิด Google Sheets : GASWS1 เมนู Tools > Script Editor… เมนู File > New > Script File ตั้งชื่อ: myscript3 สร้าง function insertData1() ตามนี้ function insertData1() { var ss=SpreadsheetApp.getActiveSpreadsheet(); var sheet=SpreadsheetApp.setActiveSheet(ss.getSheetByName(“Sheet1”)); sheet.getRange(1, 1).setValue(“Hello World”); sheet.getRange(“A2”).setValue(“สวัสดี”); var v1=[ [“ชื่อ”,”นามสกุล”,”อายุ”] ]; var v2=[ [“สมชาย”] ,[“Robert”] ,[“39”] ]; sheet.getRange(“A3:C3”).setValues(v1); sheet.getRange(“A4:A6”).setValues(v2); } เมนู Run > insertData1 สร้าง function insertData2() ตามนี้ function insertData2()…

    >> Read More <<

  • Google Apps Scripts Workshop – Level 1


    เริ่มต้นใช้งาน GAS Editor อ่าน/เขียนข้อมูลกับ Google Sheets Case Study: ตรวจสอบ Website Availability ด้วย GAS แทนที่ข้อความ ด้วยค่าใน Google Sheets การสร้างไฟล์ PDF จากข้อความที่ต้องการ การส่งอีเมลถึงผู้รับตามที่กำหนด พร้อมแนบข้อความ/ไฟล์ที่ต้องการ การส่งไฟล์ทางอีเมลแบบ Top Secret! การแสดงผลจำนวน Quota การส่งอีเมลที่ยังเหลืออยู่ในรอบ 24 ชั่วโมง

    >> Read More <<

  • Shell Script : Grouping and Summation


    มี Log ขนาดใหญ่ แล้ว ต้องการจะวิเคราะห์ข้อมูลของนาทีที่ผ่านมา เลือกเฉพาะรูปแบบที่ต้องการด้วยคำสั่ง grep ‘Apr 28 10:59’ /var/log/mail.log | grep ‘postfix/qmgr’ |grep ‘nrcpt=’ |grep -v ‘from=<>’ ได้ผลมาประมาณนี้ ต้องการเอาข้อมูล X และ Y จากรูปแบบนี้ from=<X> และ nrcpt=Y ใช้ความรู้จาก Shell Script: Extract exact pattern from string ใช้คำสั่งต่อไปนี้ grep ‘Apr 28 10:59’ /var/log/mail.log | grep ‘postfix/qmgr’ |grep ‘nrcpt=’ |grep -v ‘from=<>’|sed -n ‘s/.*\sfrom=<\(.*\)>.*\snrcpt=\(.*\)\s(.*/\1:\2/p’ ได้ผลมาประมาณนี้ ต้องการจับกลุ่มตาม คอลัมน์ที่ 1 แล้วหาผลรวมของคอลัมน์ที่…

    >> Read More <<

  • Shell Script : Extract exact pattern from string


    มี string ดังนี้ ในตัวแปร line line=’Apr 18 06:04:57 webmail squirrelmail: Message sent via webmail: by username.s (psu.ac.th) at 41.203.69.5 on 04/17/2015 23:04:57: Message-ID: 98f9739438686e127bcb8547fea7ed82.squirrel@webmail.psu.ac.th Total 9 recipients Message-ID: 98f9739438686e127bcb8547fea7ed82.squirrel@webmail.psu.ac.th’ ต้องการค่าที่อยู่ระหว่าง Total … recipients ใช้คำสั่งนี้ total=$(echo $line | sed -n ‘s/.*Total \([[:digit:]]*\) recipients.*/\1/p’) ตัวแปร $total จะมีค่า 9 ตามที่ต้องการ อธิบาย คำสั่ง sed -n ‘s/PATTERN/&/p’ จะแสดงข้อความที่ตรงกับ Pattern เท่านั้น…

    >> Read More <<