ÔÚ¹¤×÷ÖÐÅöµ½ÕâÑùÒ»¸öÎÊÌ⣺
ÎÒÔÚ²âÊÔÒ»¸ö·þÎñÆ÷ÉϵijÌÐò£¬
²âÊÔµÄʱºòÿ´Î²Ù×÷¶¼»á²úÉúÒ»¸öLOGÎļþ£¬
Äܹ»ÖªµÀÎļþÃûºÍ´æ·ÅµÄĿ¼£¨²âÊÔ»ÃæÓÐÏÔʾ£©¡£
Èç¹û·¢ÏÖLOGÎļþÉÏÊä³ö´íÎóµÄ»°¾ÍÐèÒª²éÕÒÔÒò£¬
Èç¹ûûÓдíÎóµÄ»°£¬¾ÍÒª°ÑLOGÎļþ±£ÁôÏÂÀ´×÷Ϊ²âÊÔµÄÖ¤¾Ý¡£
ÎÊÌâÊÇ·þÎñÆ÷ÉÏ´æ·ÅµÄLOGÎļþÌ«¶àÁË£¨·þÎñÆ÷²»ÊÇÎÒÄܹ»¿ØÖƵģ©£¬
ÓÃFTP¹¤¾ßÔÚÏÔʾÎļþÒ»ÀÀµÄʱºò¾ÍËÀÁË£¬¹ýÂËÎļþÃûÒ²²»ÐС£
ÔÚÖÕ¶ËÉÏÊÖ¶¯FTPµÄ»°£¬1·ÖÖÓÄÚ²»Ïò·þÎñÆ÷·¢¸öÃüÁî¾Í±»Ìß³öÀ´¡£
ËùÒÔÒ»Ö±ÓÃssh²é¿´LOG£¬¿´µ½ÕýÈ·ÁËÔÚÓÃftpÃüÁîÏÂÔØ¡£
ÕâÑùÌ«Âé·³ÁË£¬ËùÒÔ×Ô¼º²é×ÊÁÏ£¬·¢¾õFTP»¹¿ÉÒÔÕâÑùʹÓá£
´ò¿ªÒ»¸öÎļþÊäÈ룺[code]
#!/bin/bash
if [ $# -eq 0 ]
then
echo "ÇëÊäÈëÎļþÃû"
exit 1
fi
LOGFILE=`mktemp -t ftplog.XXXXXXXXX` || exit 1
ftp -inv <
open server
user username password
get /var/log/test/$1 ./$1
bye
END
CNT=`grep -c '226 File send OK.' $LOGFILE`
if [ $CNT -eq 0 ]
then
echo "Îļþ´«ËÍʧ°Ü"
else
cat ./$1
fi
rm -f $LOGFILE
[/code]ÉÏÊöµÄÀý×ÓÀ
server ·þÎñÆ÷
username ̞
password ÃÜÂë
/var/log/test/ LOGµÄĿ¼
°ÑÎļþ±£´æΪget.sh£¬È»ºó¸¶ÉÏÖ´ÐÐȨÏÞ¡£
ʹÓ÷½·¨£º
°ÑÎļþ¿½±´ÄãÏëÒª´æ·ÅÎļþµÄÄǸöĿ¼£¨µ±È»¿ÉÒԷŵ½/usr/bin/ÀïÃæÈ¥£©
È»ºóÔÚÖÕ¶ËÀï½øÈëÄǸöĿ¼£¬ÊäÈë
./get.sh LOGÎļþÃû
ÕâÑù¾Í¿ÉÒÔ°ÑLOGÎļþ±£´æµ½±¾µØĿ¼£¬
Èç¹ûÎļþ²»´æÔÚ¾ÍÏÔʾ£ÛÎļþ´«ËÍʧ°Ü£Ý
ÏÂÔسɹ¦µÄ»°¾ÍÏÔʾÎļþÄÚÈÝ¡£
h657609324 ÓÚ 2013-08-28 17:08:59·¢±í:
ÓеãÔΣ¬²»¹ý»¹ÊÇÃ÷°×ÁË
jinlong1996 ÓÚ 2013-07-24 10:02:15·¢±í:
ding!
farseerlee ÓÚ 2013-07-16 14:01:54·¢±í:
ͦºÃ£¬ÀûÓÃshellÊ¡È¥Á˲»ÉÙÇÃÃüÁîµÄ²½Öè
wst021 ÓÚ 2010-06-09 21:03:39·¢±í:
·Ç³£ºÃ°¡£¬ÖµµÃѧϰ²Î¿¼¡£
shenhao0129 ÓÚ 2010-06-09 20:20:04·¢±í:
ºÃÏñÎÒûÓнӴ¥Linux֮ǰ£¬Ò²Ð´ÁËÒ»¸öÀàËƵÄbatÅú´¦ÀíÀ´×öÀàËƵÄÊÂÇ飬µ«Êǹ¦ÄÜԶûÓÐLZµÄÕâôǿ´ó£¬ºÇºÇ£¡Åå·þ
Çó֪·ÂþÂþ ÓÚ 2010-06-02 13:11:30·¢±í:
:0wl;l1
shen.yhx ÓÚ 2010-04-27 11:57:31·¢±í:
ѧϰÖÐ
balini ÓÚ 2009-07-23 19:26:40·¢±í:
(e:e2s
wula9707 ÓÚ 2009-07-08 17:36:01·¢±í:
²»¶® ѧϰ¡£¡£¡£
yzm890425 ÓÚ 2009-07-06 00:31:27·¢±í:
Õâ¸öÊÇ×öʲôÓÃµÄ ºÃ¸´ÔÓŶ
Áõ³å ÓÚ 2009-07-04 18:20:48·¢±í:
ÔÀ´FTP»¹¿ÉÒÔÕâÑùÓã¡
csl0371 ÓÚ 2009-07-04 13:21:09·¢±í:
¿ÉÊÇÎÒÍêÈ«¿´²»¶®¡£¡£¡£
yangshan ÓÚ 2009-07-02 23:47:58·¢±í:
¸ßÈË£¡:ha3nd
ffsedan ÓÚ 2009-06-25 12:44:39·¢±í:
Å£°¡
bbsytc ÓÚ 2009-06-25 10:01:36·¢±í:
ѧϰÁË ºÜ²»´íµÄFTP
jianwugy ÓÚ 2009-06-22 00:43:44·¢±í:
лл ¹þ¹þ{:3_111:}
Áõ³å ÓÚ 2009-06-18 22:29:39·¢±í:
²»´Ö£¬Ö§³Ö£¡
cwqing1973 ÓÚ 2009-06-17 16:48:22·¢±í:
Ö§³Öһϣ¬ÖªÊ¶ÊÇѧÎÞÖ¹¾³µÄ£¡ÖªÊ¶Ò²ÊÇÁéÐԵġ£
henryhj ÓÚ 2009-06-14 23:25:35·¢±í:
½ñÌìÎÒÏë×öÒ»¼þ¼òµ¥µÄÊÂÇ飬²î²»¶àÒ²¾ÍÊÇread½øÒ»¸ö×Ö´®£¬È»ºóºóÃæ×öһЩ²Ù×÷£¬ÏëÓÃcmdÊÔÏ£¬°ëÌìûÕÞ£¬¾õµÃcmdÃüÁî²»Ôõô¼òµ¥¹¦Äܵ¹ÊÇÏ൱¼òµ¥£¬)3):o »¹ÊÇbashºÃÓÃ(6)m:b
super123 ÓÚ 2009-06-14 21:55:27·¢±í:
ºÃ£¡Ñ§Ï°ÁË.........
jagub ÓÚ 2009-06-14 21:45:47·¢±í:
дshellû·Ñ¶àÉÙʱ¼ä£¬DOS°æµÄ¿ÉÊÇ»¨Á˺ü¸Ìì²Å¸ã¶¨µÄ:0w223dc
zenwall ÓÚ 2009-06-14 21:25:22·¢±í:
ѧϰÁË Ð»Ð» ¹þ¹þ
СÆÕÁÖ˹ ÓÚ 2009-06-14 16:53:57·¢±í:
(e:e2s
icejoywoo ÓÚ 2009-06-14 16:33:19·¢±í:
ºÃ¶à°¡
xlsogb ÓÚ 2009-06-14 00:03:13·¢±í:
àÞ£¬ºÃ¸´ÔÓ
jagub ÓÚ 2009-06-13 22:11:23·¢±í:
[i=s] ±¾Ìû×îºóÓÉ jagub ÓÚ 2009-6-13 22:16 ±à¼ [/i]
ÖÜΧµÄÐÖµÜÃÇÏòÎÒÒªÕâ¸ö³ÌÐò£¬µ«ÊÇËûÃǵĻúÆ÷ÊÇwindowsXP
ËùÒÔÎÒÓÖдÁ˸öDOS°æµÄ
±ðС¿´ÁËDOS£¬ÏÖÔÚµÄDOSÒ²ºÜÅ£µÄ£¨µ±È»±ÈÆðShell£¬ÄÇÊÇС¶ù¿ÆÁË£©
´ò¿ªÒ»¸öÎļþÊäÈë[code]
@echo off
setlocal
if .%1==. (
echo ÇëÊäÈëÎļþÃû
goto end
)
set file=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%%TIME:~3,2%%TIME:~6,2%%TIME:~9,2%
set cmdfile=%temp%\%file%.ftp
set logfile=%temp%\%file%.log
echo open server>%cmdfile%
echo user username password>>%cmdfile%
echo asci>>%cmdfile%
echo mget /var/log/test/%1>>%cmdfile%
echo bye>>%cmdfile%
ftp -i -n -s:%cmdfile%>%logfile%
set /a scnt=0
for /F "usebackq" %%A in (`findstr /C:"226 File send OK." %logfile%`) do set /a scnt+=1
del %cmdfile%
del %logfile%
if %scnt% EQU 0 (
echo Îļþ´«ËÍʧ°Ü
) else (
type %1
)
:end
endlocal
[/code]ͬÑùÉÏÊöµÄÀý×ÓÀ
server ·þÎñÆ÷
username ̞
password ÃÜÂë
/var/log/test/ LOGµÄĿ¼
°ÑÎļþÃû±£´æΪget.bat£¬
ʹÓ÷½·¨£º
°ÑÎļþ¿½±´µ½´æ·ÅÎļþµÄÄǸöĿ¼£¬ÔÚCMD´°¿ÚÀï½øÈëÄǸöĿ¼£¬ÊäÈë
get ÎļþÃû
DOS°æµÄºÍLinuxÉϵÄÓÐЩ²»Í¬
1£¬FTPµÄ -v ²ÎÊý£¬LinuxµÄFTPÊÇÏÔʾ·þÎñÆ÷´«Ë͵ÄÏûÏ¢£¬DOSµÄFTPÊDz»ÏÔʾ·þÎñÆ÷´«Ë͵ÄÏûÏ¢
2£¬FTPµÄgetÃüÁLinuxµÄFTP£¬Èç¹û·þÎñÆ÷ÉÏÎļþ²»´æÔڵĻ°£¬ÊDz»»áÔÚ±¾µØ½¨Á¢ÎļþµÄ¡£DOSµÄFTP»á½¨Ò»¸ö0×Ö½ÚµÄÎļþ¡£ËùÒÔDOS°æµÄ¸Ä³ÉmgetÁË
3£¬DOS°æµÄ»Ø³µÊÇCRLF£¬LinuxµÄÊÇLF£¬ËùÒÔDOS°æÓõÄÊÇASCIIģʽÏÂÔصÄ