Bash 脚本命令问题

发布于 2024-10-05 05:26:59 字数 1928 浏览 2 评论 0原文

当我在 cygwin 中输入以下命令时,

bin/nutch index crawl/crawldb crawl/linkdb crawl/segment/* 

二进制文件可以正常工作。当我将完全相同的行放入 bash 脚本中时:

#!/bin/bash/
bin/nutch index crawl/crawldb crawl/linkdb crawl/segment/*

我收到一条错误消息,指出某些文件不存在。这可能是我正在运行的程序 Nutch 特有的,但我认为它与我在脚本中调用命令的方式有更多关系。关于出了什么问题以及如何解决这个问题有什么想法吗? (是的,我正在使用制表符完成)

编辑:

脚本:

#!/bin/bash
/home/Dan/apache-nutch-1.2/bin/nutch index crawl/indexes crawl/crawldb crawl/linkdb crawl/segments/*

我运行命令:

$ pwd
/home/Dan/apache-nutch-1.2
$ ./nutch.sh

我得到的输出是:

Indexer: starting at 2010-11-29 15:15:44
Indexer: org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/crawl_fetch
Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/crawl_parse
Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/parse_data
Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/parse_text
    at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:190)
    at org.apache.hadoop.mapred.SequenceFileInputFormat.listStatus(SequenceFileInputFormat.java:44)
    at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:201)
    at org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:810)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:781)
    at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:730)
    at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1249)
    at org.apache.nutch.indexer.Indexer.index(Indexer.java:76)
    at org.apache.nutch.indexer.Indexer.run(Indexer.java:97)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
    at org.apache.nutch.indexer.Indexer.main(Indexer.java:106)

问候, ~DS

I when I type the following command into cygwin:

bin/nutch index crawl/crawldb crawl/linkdb crawl/segment/* 

then the binary works fine. When I place the exact same line into my bash script:

#!/bin/bash/
bin/nutch index crawl/crawldb crawl/linkdb crawl/segment/*

I get an error saying some files don't exist. This may be specific to Nutch which is the program I'm running, but I think it has more to do with how I'm calling the command in the script. Any ideas about what's wrong and how to fix this? (yes I'm using tab completion)

EDIT:

Script:

#!/bin/bash
/home/Dan/apache-nutch-1.2/bin/nutch index crawl/indexes crawl/crawldb crawl/linkdb crawl/segments/*

I run the command:

$ pwd
/home/Dan/apache-nutch-1.2
$ ./nutch.sh

The output I'm getting is:

Indexer: starting at 2010-11-29 15:15:44
Indexer: org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/crawl_fetch
Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/crawl_parse
Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/parse_data
Input path does not exist: file:/C:/cygwin/home/Dan/apache-nutch-1.2/
/parse_text
    at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:190)
    at org.apache.hadoop.mapred.SequenceFileInputFormat.listStatus(SequenceFileInputFormat.java:44)
    at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:201)
    at org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:810)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:781)
    at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:730)
    at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1249)
    at org.apache.nutch.indexer.Indexer.index(Indexer.java:76)
    at org.apache.nutch.indexer.Indexer.run(Indexer.java:97)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
    at org.apache.nutch.indexer.Indexer.main(Indexer.java:106)

Regards,
~DS

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小情绪 2024-10-12 05:26:59

有两件事:

  1. 在脚本开头的 shebang 中的“bash”后面有一个尾随斜杠 - 删除它,它应该只是读取 #!/bin/bash。还要仔细检查 /bin 中是否有 bash
  2. 该脚本将尝试从当前文件夹中的 bin 目录执行 nutch。因此,如果您位于 $HOME 中,并假设您有一个路径 $HOME/bin/nutch,那么就可以了。但是,如果您更改为 /tmp,那么它将失败,因为没有 /tmp/bin/nutch 这样的路径。您最好首先为 nutch 提供完整的绝对路径名。

Two things:

  1. You've got a trailing slash after "bash" in the shebang at the start of the script -- remove it, it should just read #!/bin/bash. Also double check there is a bash in /bin.
  2. The script will try and execute nutch from the bin directory in your currect folder. So if you're in $HOME, and assuming you've got a path $HOME/bin/nutch, then you'll be okay. But then if you change to /tmp, then it'll fail as there's no such path as /tmp/bin/nutch. You're better off giving the full absolute path name to nutch in the first place.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文