【发布时间】:2016-08-26 11:45:00
【问题描述】:
好的,所以我有以下脚本可以从 url 列表 (urls.txt) 中抓取联系人详细信息。当我直接从终端运行以下命令时,我得到了正确的结果
perl saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' http://url.com
但是,当我从脚本中调用上述命令时,我得到“没有这样的文件或目录”的结果
这是我的脚本的副本
#!/bin/bash
while read inputline
do
//Read the url from urls.txt
url="$(echo $inputline)"
//execute saxon-lint to grab the contents of the XPATH from the url within urls.txt
mydata=$("perl saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' $url ")
//output the result in myfile.csv
echo "$url,$mydata" >> myfile.csv
//wait 4 seconds
sleep 4
//move to the next url
done <urls.txt
我尝试将 perl 更改为 ./ 但得到相同的结果
谁能告诉我这哪里出了问题
我收到的错误是
./script2.pl: line 6: ./saxon-lint.pl --html --xpath 'string-join(//div[2]/div[2]/div[1]/div[2]/div[2])' http://find.icaew.com/listings/view/listing_id/20669/avonhurst-chartered-accountants : No such file or directory
提前致谢
【问题讨论】:
-
尝试使用绝对路径。
-
试过但结果相同
-
使用
\ to escape the/ -
标题中声称的 perl 中的这个 perl 如何?这是 bash 中的 perl。
-
我是 linux 新手,所以你必须原谅使用的术语