---
title: "nutch0.9 NT批处理文件"
author: "fuyangchang"
date: "2007-06-28T14:34:00Z"
tags: []
categories: ["企业架构"]
slug: "nutch0-9-nt"
draft: false
lastmod: "2007-06-28T14:34:00Z"
id: 95060
url: "https://csdn.iteye.com/blog/95060"
---

nutch0.9 NT批处理文件

@echo off  
rem \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\**  
rem * A script to launch nutch on Windows 2000/XP System.  
rem *  
rem * Written by babatu  
rem * babatu@gmail.com blog: blog.babatu.com  
rem *  
rem * Because delayed environment is used, cmd /V:on should be used to  
rem * run this script.  
rem \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\**  
if "%OS%"=="Windows\_NT" @setlocal  
if "%OS%"=="WINNT" @setlocal

if "%1" == "" goto :msg  
goto :begin  
:msg  
echo "Usage: nutch COMMAND"  
 echo "where COMMAND is one of:"  
 echo "  crawl             one-step crawler for intranets"  
 echo "  readdb            read / dump crawl db"  
 echo "  readlinkdb        read / dump link db"  
 echo "  inject            inject new urls into the database"  
 echo "  generate          generate new segments to fetch"  
 echo "  fetch             fetch a segment's pages"  
 echo "  parse             parse a segment's pages"  
 echo "  segread           read / dump segment data"  
 echo "  updatedb          update crawl db from segments after fetching"  
 echo "  invertlinks       create a linkdb from parsed segments"  
 echo "  index             run the indexer on parsed segments and linkdb"  
 echo "  merge             merge several segment indexes"  
 echo "  dedup             remove duplicates from a set of segment indexes"  
 echo "  plugin            load a plugin and run one of its classes main()"  
 echo "  server            run a search server"  
 echo " or"  
 echo "  CLASSNAME         run the class named CLASSNAME"  
 echo "Most commands print help when invoked w/o parameters."  
pause  
goto :end

:begin  
rem %~dp0 这个脚本的扩展path   ( expanded pathname of the current script under NT)  
set DEFAULT\_NUTCH\_HOME=%~dp0  
rem set DEFAULT\_NUTCH\_HOME=..

if "%NUTCH\_HOME%"=="" set NUTCH\_HOME=%DEFAULT\_NUTCH\_HOME%  
set DEFAULT\_NUTCH\_HOME=""  
rem 设置默认DEFAULT\_NUTCH\_HOME

echo %NUTCH\_HOME%

rem set \_USE\_CLASSPATH=yes

if "%CLASSPATH%"=="" ( set CLASSPATH=%JAVA\_HOME%\\lib\\tools.jar) ELSE set CLASSPATH=%CLASSPATH%;%JAVA\_HOME%\\lib\\tools.jar

set CLASSPATH=%CLASSPATH%;%NUTCH\_HOME%conf;  
echo %CLASSPATH%  
echo before other

rem for developers, add plugins, job & test code to CLASSPATH  
if exist %NUTCH\_HOME%\\build\\plugins set CLASSPATH=%CLASSPATH%%NUTCH\_HOME%build;

for /R %NUTCH\_HOME%\\build %%i in (nutch\*.job) do set CLASSPATH=!CLASSPATH!;%%i

if exist %NUTCH\_HOME%\\build\\test\\classes set CLASSPATH=%CLASSPATH%;%NUTCH\_HOME%\\build\\test\\classes

rem for releases, add Nutch job to CLASSPATH  
for /R %NUTCH\_HOME% %%i in (nutch\*.job) do set CLASSPATH=!CLASSPATH!;%%i  
rem add plugins to classpath  
if exist %NUTCH\_HOME%\\plugins set CLASSPATH=%CLASSPATH%;%NUTCH\_HOME%  
rem add libs to CLASSPATH  
for /R %NUTCH\_HOME%\\lib %%f in (\*.jar) do set CLASSPATH=!CLASSPATH!;%%f

echo %CLASSPATH%

rem translate command  
if "%1"=="crawl" set CLASS=org.apache.nutch.crawl.Crawl  
if "%1"=="inject" set   CLASS=org.apache.nutch.crawl.Injector  
if "%1"=="generate" set   CLASS=org.apache.nutch.crawl.Generator  
if "%1"=="fetch" set   CLASS=org.apache.nutch.fetcher.Fetcher  
if "%1"=="parse" set   CLASS=org.apache.nutch.parse.ParseSegment  
if "%1"=="readdb" set   CLASS=org.apache.nutch.crawl.CrawlDbReader  
if "%1"=="readlinkdb" set   CLASS=org.apache.nutch.crawl.LinkDbReader  
if "%1"=="segread" set   CLASS=org.apache.nutch.segment.SegmentReader  
if "%1"=="updatedb" set   CLASS=org.apache.nutch.crawl.CrawlDb  
if "%1"=="invertlinks" set   CLASS=org.apache.nutch.crawl.LinkDb  
if "%1"=="index" set   CLASS=org.apache.nutch.indexer.Indexer  
if "%1"=="dedup" set   CLASS=org.apache.nutch.indexer .DeleteDuplicates  
if "%1"=="merge" set   CLASS=org.apache.nutch.indexer.IndexMerger  
if "%1"=="plugin" set   CLASS=org.apache.nutch.plugin.PluginRepository  
if "%1"=="server" set CLASS='org.apache.nutch.searcher.DistributedSearch$Server'  
if "%CLASS%"=="" set CLASS=%1  
echo "aa"  
%JAVA\_HOME%\\bin\\java -cp %CLASSPATH% %CLASS% %*  
echo "bnb"

if "%OS%"=="Windows\_NT" @endlocal  
if "%OS%"=="WINNT" @endlocal

:end