ข่าว: ข่าวประกาศ

  • 24 พฤษภาคม 2024, 21:31:19

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ผู้เขียน หัวข้อ: วิธีแสดงผลข้อความจากไฟล์ rc.local ในขณะที่บูตบน Ubuntu  (อ่าน 7099 ครั้ง)

admin

  • Administrator
  • Hero Member
  • *****
  • กระทู้: 3820
    • ดูรายละเอียด
    • อีเมล์
สำหรับผู้ที่ทำแผ่นติดตั้ง หรือทำสคริปตอนบูต แล้วเจอปัญหาว่า Ubuntu 9.10 เป็นต้นไป

ไม่สามารถแสดงผลข้อความจากสคริปที่เขียนไว้ได้ เช่น เขียนไว้ใน rc.local เป็นต้น เพื่อแสดงผลหรือแสดงค่าต่าง ๆ

วิธีทำก็คือ ให้ส่งข้อความไปแสดงที่  /dev/console แทน ยกตัวอย่างเช่น ไฟล์ /etc/rc.local

#!/bin/sh
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo "Hello This is rc.local message" > /dev/console

exit 0

เพียงเท่านี้ก็จะสามารถแสดงผลข้อความให้เห็นในขณะที่บูตได้ครับ



ลองนำไปศึกษาปรับแต่งเพิ่มเติมกันดูนะครับ

<a href="http://www.hadyaiinternet.com/images/inetcafe.swf" target="_blank" rel="noopener noreferrer" class="bbc_link bbc_flash_disabled new_win">http://www.hadyaiinternet.com/images/inetcafe.swf</a>


There are no comments for this topic. Do you want to be the first?