多个wget命令的bash脚本

时间:2015-12-03 20:49:08

标签: bash wget

我有多个(超过100个)类似于此:

wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2009_02//00031327004/auxil/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2009_01//00031327001/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2010_12//00031856009/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2008_01//00031043003/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2012_01//00032237004/uvot/

我被告知使用bash脚本可以非常快速轻松地完成此操作,如果有可能,有人可以为我提供一个示例吗?我需要在脚本中包含什么内容?为我的n00b问题道歉,但......我是一个人!

2 个答案:

答案 0 :(得分:2)

假设您的网址列表如下所示:

while

使用#!/bin/bash while read url; do wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks "$url" done < urls.txt 循环从文本文件中<form method="post" action="test.php" name="Work Record" autocomplete="off"> <input type="text" name="first_name" id="staff_name2" placeholder="First" required /> <input type="text" name="last_name" id="staff_name" placeholder="Last" required /> <input name="checkbox" type="checkbox" class="head-l" id="checkbox" onChange="this.form.submit()"> 建立您的网址:

<?php
require '/home/newnplhftp/nplh.us/smtp/phpmailer/class.phpmailer.php';

$mail = new PHPMailer;

$mail->IsSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';  // Specify main and backup server
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'xxxxxxxxxxxxxxxx';                            // SMTP username
$mail->Password = 'xxxxxxxxx';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable encryption, 'ssl' also accepted
$mail->Port = 465;                    // set the SMTP port for the GMAIL server

$mail->From = 'xxxxxxxxxxxxxx';
$mail->FromName = 'NPLH';
$mail->AddAddress('xxxxxxxxxxxxxxxxxxxxx');               // Name is optional

$mail->AddCC('');
$mail->AddBCC('');

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters

$mail->IsHTML(true);                                  // Set email format to HTML

$mail->Subject = 'xxxxxxxxxxxxxxx';

$mail->Body = '
<html>
<h2><b>$first_name $last_name, $license_type</b></h2>
</html>';

$mail->AltBody = '';

if(!$mail->Send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}

echo 'Thank you, your message has been sent!';

?>

答案 1 :(得分:0)

假设你的noob问题是关于加快处理时间,

您可以在后台&wait中为他们生成多个流程

wget firsturl &
wget secondurl &
...
wait