【问题标题】:Using wgets to connect to sites in a txt file using shell scripting使用 wgets 使用 shell 脚本连接到 txt 文件中的站点
【发布时间】:2013-02-23 09:58:06
【问题描述】:

我正在尝试创建一个脚本,该脚本使用 wgets 来访问文件列表中的每个 url。但是,当这样做而不是访问 website.com 时,它将尝试连接到 website.com/r/n。我知道这与文本编辑器中的文本格式有关,但我不确定如何让我的程序忽略这一点。这是我的代码:

    #!/bin/bash
    for i in `cat $1`
    do
    wget --spider $i 
    if wget --spider $i 2>&1 | grep --quiet "200 OK" ; then
        echo $i >> connected.txt
    else
        echo $i >> unsuccesful.txt
    fi
    rm wget-log
    done

【问题讨论】:

    标签: file shell scripting


    【解决方案1】:

    将此添加到脚本的顶部

    dos2unix "$1"
    

    IHTH

    【讨论】:

      猜你喜欢
      • 2013-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-03
      • 1970-01-01
      • 2018-12-31
      • 2012-04-06
      • 2021-10-31
      相关资源
      最近更新 更多