2010-07-29 3 views
0

wget을 사용하여 파일을 다운로드하는 기본 bash 스크립트를 작성하는 방법을 알고 있지만이 작업을 무한 루프로 실행하여 지정된 파일을 다운로드하고 다운로드가 완료되면 삭제 한 다음 다시 다운로드하십시오 .대역폭을 소비 중입니다

+2

무엇 대역폭을 소비 당신이 끝없이 다운로드하기 이라며 알았는데? – danben

+0

프로그램/스크립트가 종료 될 때까지 가정 인터넷 연결 대역폭을 100 % 사용하십시오. – oshirowanen

+1

누군가에게 문제를 일으키기 위해이 작업을 수행하려고합니까, 아니면 합법적 인 목적이 있습니까? 이런 종류의 일을하는 이유가 있지만, 보통 이런 식으로 표현되지는 않습니다. –

답변

5

당신은 파일, 출력하지 쓸모없는 정보를 저장하고,에 /dev/null

편집에 또 다시 내용을 덤프하지 않습니다

while : 
do 
    wget -O - -q "http://some.url/" > /dev/null 
done 

이 찾고있는 단지 대역폭을 소비하고 사용하십시오 ping -f 또는 ping -f -s 65507

+0

첫 번째 스크립트는 이해하지만 핑 -f 또는 ping -f -s 65507은 무엇을하고 있습니까? – oshirowanen

+1

'-f'는 flood ping을 나타내며'-s 65507'은 패키지 크기를 65507 바이트 – LukeN

+0

으로 설정합니다. 실제로 65507 + 8 (icmp 헤더) + 20 (ip 헤더) 당신이 보낼 수있는 가장 큰 ipv4 패킷 인 65535 (또는 0xffff)를 만듭니다. (그것은 전선에 가기 전에 잘게 될 것입니다.) – mvds

1

프로그래밍으로 모든 것이 가능합니다. :)

인터넷 대역폭을 최대한 활용하려면 wget의 많은 프로세스를 시작할 수 있고 큰 디스크 이미지 파일을 동시에 다운로드 할 수 있으며 동시에 거대한 파일을 다시 보냅니다. 일부 서버.

세부 정보는 구현을 위해 남겨 두지 만 대역폭을 최대한 활용할 수있는 방법 중 하나입니다.

+0

재미있는데, wget을 사용하여 기본 스크립트를 작성하는 방법을 알고 있지만, 다운로드하기 전에 이미 다운로드 한 버전을 삭제하고 다시 다운로드하려면 어떻게해야합니까? – oshirowanen

+0

원본 질문이 업데이트되었습니다. – oshirowanen

1

네트워크 대역폭을 소비하려는 경우 다른 컴퓨터가 필요합니다. 그런 다음 컴퓨터 A (IP 192.168.0.1)에서 포트 (예 : 12345)를 수신합니다.

$ netcat -l -p 12345 

그런 다음 다른 컴퓨터에서 데이터를 보내십시오.

$ netcat 192.168.0.1 12345 < /dev/zero 
+0

인터넷 연결을 최대한 활용하고 싶습니다. – oshirowanen

+0

원본 질문이 업데이트되었습니다. – oshirowanen

+0

최대 대역폭을 안정적으로 소비하는 것은'ping -f'를 사용하는 것이 가장 좋습니다. 문제는'wget'에 관한 것입니다. – mvds

3

목표가 최대가되는 경우 특히 벤치마킹을위한 대역폭은 iperf을 사용하십시오. 서버 및 클라이언트에서 iperf을 실행하면 지정된 프로토콜 및 매개 변수를 사용하여 대역폭을 테스트합니다. 단방향 또는 양방향 처리량을 테스트 할 수 있으며 선택적으로 "대상"대역폭 사용률 (예 : 3Mbps)을 달성하려고 시도 할 수 있습니다.

+0

이것은 이상한 일입니다. 제 집 시스템에는 신뢰할 수없는 저장소가 없습니다. 그러나이 패키지는 신뢰할 수없는 것으로오고 있습니다. – oshirowanen

+0

@oshiorwanen : 패키지가 서명되지 않았거나 실제로 신뢰할 수없는 저장소가 있거나 뭔가가 있습니다. 귀하의 gpg에 잘못되었습니다. 그럼에도 불구하고 프로그램과 관련이 없으며 설치에 문제가 있습니다. 'iperf'는 당신이하는 일을 정확하게하도록 고안되었으며, 유연하고 잘 수행됩니다. – Borealid

+0

@oshirowanen : 다른 apt-get 업데이트를 실행하십시오. 마지막으로 릴리스 파일을 다운로드하는 데 문제가있을 수 있습니다. – derobert

0

나는 컬을 사용하여 wget을 사용한다. 그것은 더 편집 가능합니다. 여기에 SVN 버전을 확인한 bash 스크립트의 excrpt가있다. 그런 다음 사용자에게 stable 또는 latest를 다운로드 할 수있는 선택권을 준다. 그런 다음 파일의 구문을 분석하여 "사용자 설정"을 나머지 스크립트와 분리합니다.

 svnrev=`curl -s -m10 mythicallibrarian.googlecode.com/svn/trunk/| grep -m1 Revision | sed s/"<html><head><title>mythicallibrarian - "/""/g| sed s/": \/trunk<\/title><\/head>"/""/g` 

if ! which librarian-notify-send>/dev/null && test "$LinuxDep" = "1"; then 
    dialog --title "librarian-notify-send" --yesno "install librarian-notify-send script for Desktop notifications?" 8 25 
    test $? = 0 && DownloadLNS=1 || DownloadLNS=0 
    if [ "$DownloadLNS" = "1" ]; then 
     curl "http://mythicallibrarian.googlecode.com/files/librarian-notify-send">"/usr/local/bin/librarian-notify-send" 
     sudo chmod +x /usr/local/bin/librarian-notify-send 
    fi 
fi 

if [ ! -f "./librarian" ]; then 
    DownloadML=Stable 
    echo "Stable `date`">./lastupdated 
else 

lastupdated="`cat ./lastupdated`" 
DownloadML=$(dialog --title "Version and Build options" --menu "Download an update first then Build mythicalLibrarian" 10 70 15 "Latest" "Download and switch to SVN $svnrev" "Stable" "Download and switch to last stable version" "Build" "using: $lastupdated" 2>&1 >/dev/tty) 
if [ "$?" = "1" ]; then 
    clear 
    echo "mythicalLibrarian was not updated." 
    echo "Please re-run mythicalSetup." 
     echo "Done." 
    exit 1 
fi 
fi 
clear 
if [ "$DownloadML" = "Stable" ]; then 
    echo "Stable "`date`>"./lastupdated" 
    test -f ./mythicalLibrarian.sh && rm -f mythicalLibrarian.sh 
    curl "http://mythicallibrarian.googlecode.com/files/mythicalLibrarian">"./mythicalLibrarian.sh" 
    cat "./mythicalLibrarian.sh"| sed s/' '/'\\t'/g |sed s/'\\'/'\\\\'/g >"./mythicalLibrarian1" #sed s/"\\"/"\\\\"/g | 
    rm ./mythicalLibrarian.sh 
    mv ./mythicalLibrarian1 ./mythicalLibrarian.sh 
    parsing="Stand-by Parsing mythicalLibrarian" 
    startwrite=0 
    test -f ./librarian && rm -f ./librarian 
    echo -e 'mythicalVersion="'"`cat ./lastupdated`"'"'>>./librarian 
    while read line 
    do 
     test "$line" = "########################## USER JOBS############################" && let startwrite=$startwrite+1 
     if [ $startwrite = 2 ]; then 
      clear 
      parsing="$parsing""." 
      test "$parsing" = "Stand-by Parsing mythicalLibrarian......." && parsing="Stand-by Parsing mythicalLibrarian" 
      echo $parsing 
      echo -e "$line" >> ./librarian 
     fi 
    done <./mythicalLibrarian.sh 

    clear 
    echo "Parsing mythicalLibrarian completed!" 
    echo "Removing old and downloading new version of mythicalSetup..." 
    test -f ./mythicalSetup.sh && rm -f ./mythicalSetup.sh 
    curl "http://mythicallibrarian.googlecode.com/files/mythicalSetup.sh">"./mythicalSetup.sh" 
    chmod +x "./mythicalSetup.sh" 
    ./mythicalSetup.sh 
    exit 0 

fi 
if [ "$DownloadML" = "Latest" ]; then 
    svnrev=`curl -s mythicallibrarian.googlecode.com/svn/trunk/| grep -m1 Revision | sed s/"<html><head><title>mythicallibrarian - "/""/g| sed s/": \/trunk<\/title><\/head>"/""/g` 
    echo "$svnrev "`date`>"./lastupdated" 
    test -f ./mythicalLibrarian.sh && rm -f mythicalLibrarian.sh 
    curl "http://mythicallibrarian.googlecode.com/svn/trunk/mythicalLibrarian">"./mythicalLibrarian.sh" 
    cat "./mythicalLibrarian.sh"| sed s/' '/'\\t'/g |sed s/'\\'/'\\\\'/g >"./mythicalLibrarian1" #sed s/"\\"/"\\\\"/g | 
    rm ./mythicalLibrarian.sh 
    mv ./mythicalLibrarian1 ./mythicalLibrarian.sh 
    parsing="Stand-by Parsing mythicalLibrarian" 
    startwrite=0 
    test -f ./librarian && rm -f ./librarian 
    echo -e 'mythicalVersion="'"`cat ./lastupdated`"'"'>>./librarian 
    while read line 
    do 
     test "$line" = "########################## USER JOBS############################" && let startwrite=$startwrite+1 
     if [ $startwrite = 2 ]; then 
      clear 
      parsing="$parsing""." 
      test "$parsing" = "Stand-by Parsing mythicalLibrarian......." && parsing="Stand-by Parsing mythicalLibrarian" 
      echo $parsing 
      echo -e "$line" >> ./librarian 
     fi 
    done <./mythicalLibrarian.sh 

    clear 
    echo "Parsing mythicalLibrarian completed!" 
    echo "Removing old and downloading new version of mythicalSetup..." 
    test -f ./mythicalSetup.sh && rm -f ./mythicalSetup.sh 
    curl "http://mythicallibrarian.googlecode.com/svn/trunk/mythicalSetup.sh">"./mythicalSetup.sh" 
    chmod +x "./mythicalSetup.sh" 
    ./mythicalSetup.sh 
    exit 0 

fi 

편집

는 : 신경 끄시 고 나는

관련 문제