« »
2008-02-031.Application

117

從 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 <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: 不建議將這個 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

<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

 

參考資料:

您还可能感兴趣的内容

日志信息 »

该日志于2008-02-03 16:43由 x72 发表在1.Application分类下, 通告目前不可用,你可以至底部留下评论。

没有评论

发表评论 »


返回顶部