Perl脚本查询易趣并报告需要重新启动的项目

时间:2013-12-12 15:12:49

标签: perl bash

亲爱的所有我试图让脚本正常工作,并且不知道从哪里开始生成错误

sh:1:语法错误:重定向意外

我的剧本如下,如果有人可以提供帮助,我将非常感激


ebay.pl

#!/usr/bin/perl -w
system("/usr/local/bin/ebaycurl.sh");
open (ITEMS, "/usr/local/data/eBaystuff") or die "stuff $!";
while (<ITEMS>) {
    chomp;
    next unless /ViewItem\&amp/;
    s/Item not relisted/Item_not_relisted/g;
    s/Item relisted/Item_relisted/g;
    @words = split;
    $relist = "";
    foreach $word (@words) {
      if ($word =~ /ViewItem\&amp/) {
         print "\n";
         $print_it = 1;
         $link = $word;
         ($junk, $link) = split /f=/, $word;
         $link =~ s/&amp;/&/g;
         #system("/usr/local/bin/ebaycurlitem.sh $link >/dev/null 2>/dev/null");
         system("/usr/local/bin/ebaycurlitem.sh $link");
         open (ITEM, "/usr/local/data/eBayitem") or die "item $!";
         $relist = "";
         while (<ITEM>) {
            next unless /Relist/;
            $relist = 'relist';
         }
         #($junk, $itemid) = split /item=/, $link;
         #$itemid =~ s/\"//;
         print "$relist\t";
         next;
      }
      if (defined $print_it) {
         if ($word =~ /\>/) {
            $print_it = undef;
            ($rem, $junk) = split />/, $word;
            print "$rem";
         } else {
            $word =~ s/title=//;
            print "$word ";
         }
      }
      if ($word =~ /Item_not_relisted/ and $relist =~ /relist/) {print "\t\t\t\tNOT RELISTED";}
    }
    print "\n";
}

ebaycurl.sh

#!/bin/bash
$(COOKIE_DIR)="cat /usr/local/etc/ebay_cookie_dir)
(/usr/bin/curl --cookie "COOKIE_DIR"/cookies.txt 'http://k2b-bulk.ebay.co.uk/ws/eBayISAPI.dll?SalesRecordConsole&currentpage=SCSold&ssPageName=STRK:ME:LNLK; -o /usr/local/data/eBaystuff)"

1 个答案:

答案 0 :(得分:1)

您发布的bash脚本有很多问题。我建议阅读bash语法因为看起来你只是随意地抛出括号和引号。而不是解释每一个更正,我只是发布这个并希望它是不言自明的......

#!/bin/bash

COOKIE_DIR=$(cat /usr/local/etc/ebay_cookie_dir)

curl --cookie "$COOKIE_DIR"/cookies.txt -o /usr/local/data/eBaystuff \
    'http://k2b-bulk.ebay.co.uk/ws/eBayISAPI.dll?SalesRecordConsole&currentpage=SCSold&ssPageName=STRK:ME:LNLK'