從 Linux 發(fā)送訊息到 Windows 作業(yè)系統
Windows NT 核心的作業(yè)系統 (包括 NT、2000、XP 和以後的版本) 內建的 popup message (Messenger Service) 是一個(gè)相當方便的訊息傳遞服務(wù), 只要使用簡(jiǎn)單的 "net send" 指令即可馬上傳遞訊息給另一臺電腦, 很適合應用在需要即時(shí)反應系統問(wèn)題的地方. (
popup message 範例圖)
而 Linux 系統的 smbclient 指令就有類(lèi)似的功能, 以下是從 Linux 發(fā)送訊息到 Windows 作業(yè)系統的操作方法:
Windows 環(huán)境需求:
Windows NT / 2000 / XP 需啟動(dòng) Messenger 服務(wù):
控制臺→系統管理工具→服務(wù)→Messenger→按右鍵選“內容”→啟動(dòng)類(lèi)型:“自動(dòng)”→啟動(dòng)
Windows 95 / 98 / ME 需執行“C:\Windows\Winpopup.exe”
Linux 環(huán)境需求:
samba-client 套件
以 Hostname 為目標的執行方式:
語(yǔ)法: echo "your_message" | smbclient -M "your_hostname"
例如,傳送 Hello World! 字串給 winxp 這臺電腦:
echo ‘Hello World!‘ | smbclient -M winxp
以 IP Address 為目標的執行方式:
需撰寫(xiě) Bash Script, 內容為:
#!/bin/bash case "$1" in send) echo "$3" | smbclient -I "$2" -M `nmblookup -A "$2" | \ grep ‘<20> - ‘ | \ cut -f 2 | \ cut -d ‘ ‘ -f 1` ;; *) echo "Usage: msg send <IPaddr.> <message>" exit 1 esac
執行方式: ./msg send "ip_addr" "your_message"
例如, 傳送 Nice to meet you 字串給 192.168.1.1 這臺電腦:
./msg send 192.168.1.1 "Nice to meet you"
註 1: 不建議將這個(gè) Bash Script 取名為 "net", 因為在 samba-common 套件裡已經(jīng)有一個(gè)執行檔: /usr/bin/net
註 2: Linux 裡的 nmblookup 這個(gè)指令跟 Windows 裡的 nbtstat 很類(lèi)似
附錄 1: NetBIOS over TCP/IP ports
UDP 137 NetBIOS name
UDP 138 NetBIOS datagram
TCP 139 NetBIOS session
附錄 2: Name Number Type Usage
<computername> 00 U Workstation Service
<computername> 01 U Messenger Service
<\\_MSBROWSE_> 01 G Master Browser
<computername> 03 U Messenger Service
<computername> 06 U RAS Server Service
<computername> 1F U NetDDE Service
<computername> 20 U File Server Service
<computername> 21 U RAS Client Service
<computername> 22 U Exchange Interchange
<computername> 23 U Exchange Store
<computername> 24 U Exchange Directory
<computername> 30 U Modem Sharing Server Service
<computername> 31 U Modem Sharing Client Service
<computername> 43 U SMS Client Remote Control
<computername> 44 U SMS Admin Remote Control Tool
<computername> 45 U SMS Client Remote Chat
<computername> 46 U SMS Client Remote Transfer
<computername> 4C U DEC Pathworks TCPIP Service
<computername> 52 U DEC Pathworks TCPIP Service
<computername> 87 U Exchange MTA
<computername> 6A U Exchange IMC
<computername> BE U Network Monitor Agent
<computername> BF U Network Monitor Apps
<username> 03 U Messenger Service
<domain> 00 G Domain Name
<domain> 1B U Domain Master Browser
<domain> 1C G Domain Controllers
<domain> 1D U Master Browser
<domain> 1E G Browser Service Elections
<INet~Services> 1C G Internet Information Server
<IS~Computer_name> 00 U Internet Information Server
<computername> [2B] U Lotus Notes Server
IRISMULTICAST [2F] G Lotus Notes
IRISNAMESERVER [33] G Lotus Notes
Forte_$ND800ZA [20] U DCA Irmalan Gateway Service
Unique (U): The name may have only one IP address assigned to it. On a network device, multiple occurences of a single name may appear to be registered, but the suffix will be unique, making the entire name unique.
Group (G): A normal group; the single name may exist with many IP addresses.
Multihomed (M): The name is unique, but due to multiple network interfaces on the same computer, this configuration is necessary to permit the registration. Maximum number of addresses is 25.
Internet Group (I): This is a special configuration of the group name used to manage WinNT domain names.
Domain Name (D): New in NT 4.0
參考資料:
如何從linux上給windows發(fā)送popup消息?[轉載]如何實(shí)現linux于windows雙向收發(fā)消息? (Google 庫存網(wǎng)頁(yè))
Understanding NetBIOSPosted by Jamyy at 2005年05月03日 14:39
from:
http://cha.homeip.net/blog/archives/2005/05/_linux_windows.html#more