從 Linux 發送訊息到 Windows 作業系統

来源:百度文库 编辑:神马文学网 时间:2024/05/06 23:52:22
從 Linux 發送訊息到 Windows 作業系統
Windows NT 核心的作業系統 (包括 NT、2000、XP 和以後的版本) 內建的 popup message (Messenger Service) 是一個相當方便的訊息傳遞服務, 只要使用簡單的 "net send" 指令即可馬上傳遞訊息給另一台電腦, 很適合應用在需要即時反應系統問題的地方. (popup message 範例圖)
而 Linux 系統的 smbclient 指令就有類似的功能, 以下是從 Linux 發送訊息到 Windows 作業系統的操作方法:
Windows 環境需求:
Windows NT / 2000 / XP 需啟動 Messenger 服務:
控制台→系統管理工具→服務→Messenger→按右鍵選“內容”→啟動類型:“自動”→啟動
Windows 95 / 98 / ME 需執行“C:\Windows\Winpopup.exe”
Linux 環境需求:
samba-client 套件
以 Hostname 為目標的執行方式:
語法: echo "your_message" | smbclient -M "your_hostname"
例如,傳送 Hello World! 字串給 winxp 這台電腦:
echo ‘Hello World!‘ | smbclient -M winxp
以 IP Address 為目標的執行方式:
需撰寫 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 " 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: 不建議將這個 Bash Script 取名為 "net", 因為在 samba-common 套件裡已經有一個執行檔: /usr/bin/net
註 2: Linux 裡的 nmblookup 這個指令跟 Windows 裡的 nbtstat 很類似
附錄 1: NetBIOS over TCP/IP ports
UDP 137 NetBIOS name
UDP 138 NetBIOS datagram
TCP 139 NetBIOS session
附錄 2: Name Number Type Usage
00 U Workstation Service
01 U Messenger Service
<\\_MSBROWSE_> 01 G Master Browser
03 U Messenger Service
06 U RAS Server Service
1F U NetDDE Service
20 U File Server Service
21 U RAS Client Service
22 U Exchange Interchange
23 U Exchange Store
24 U Exchange Directory
30 U Modem Sharing Server Service
31 U Modem Sharing Client Service
43 U SMS Client Remote Control
44 U SMS Admin Remote Control Tool
45 U SMS Client Remote Chat
46 U SMS Client Remote Transfer
4C U DEC Pathworks TCPIP Service
52 U DEC Pathworks TCPIP Service
87 U Exchange MTA
6A U Exchange IMC
BE U Network Monitor Agent
BF U Network Monitor Apps
03 U Messenger Service
00 G Domain Name
1B U Domain Master Browser
1C G Domain Controllers
1D U Master Browser
1E G Browser Service Elections
1C G Internet Information Server
00 U Internet Information Server
[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发送popup消息?[转载]如何实现linux于windows双向收发消息? (Google 庫存網頁)Understanding NetBIOS
Posted by Jamyy at 2005年05月03日 14:39
from: http://cha.homeip.net/blog/archives/2005/05/_linux_windows.html#more