#!/bin/sh

DATE=`date '+%Y%m%d'`

# login remote device which ip address is 10.18.x.x 
# remote copy the file whose name is product-server.log or product-agent.log
# save it to local disk /tmp with rename it as define format
# $1 is the first variable and $2 is the second variable you input behind the command.Same as %1 %2 in DOS.

scp user1@10.18.$1:/var/log/product-$2/product-$2.log /tmp/product-$2.$DATE.log

# open the log file fetched and you  can go through it now
open "/tmp/product-$2.$DATE.log"
~     
                           
Console input and result:

root@ ./logfly.sh 3.141 server
product-server.log                                                  100% 8333KB   8.1MB/s   00:01    

root$ ./logfly.sh 3.141 agent
product-agent.log                                                   100% 2866     2.8KB/s   00:00    

posted on 2009-08-11 22:48  Cyndi  阅读(112)  评论(0)    收藏  举报