Results 1 to 7 of 7

Thread: Launch 10 for loops in 10 gnome-terminals

  1. #1
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Launch 10 for loops in 10 gnome-terminals

    Having recently discovered for looping and wget with the -pk options, I would like to try my hand at mirroring an entire site. I have created a shell script that, in theory, should launch 10 scripts with for-looped wgets each in their own terminal window.

    It looks like it works at first, 10 windows open just fine, but they immediately shut. Running the scripts individually works just fine, but launching them all at once does not work.

    Could any bash guru out there give me a hand?
    Technomancy
    The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

  2. #2
    Join Date
    Jan 2007
    Location
    Location: Location:
    Beans
    1,246
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Launch 10 for loops in 10 gnome-terminals

    Post the script, else no-one will be able to help ya.
    clear && echo paste url and press enter; read paste; (youtube-dl $paste) | zenity --progress --title="" --text "Downloading, please wait" --auto-close --pulsate && ans=$(zenity --file-selection); gnome-terminal -x mplayer "$ans"

  3. #3
    Join Date
    Jan 2007
    Location
    Location: Location:
    Beans
    1,246
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Launch 10 for loops in 10 gnome-terminals

    You probably just need to nest each xterm or gnome-terminal call in a do-while loop so the terms stay open. Or even use -t

    xterm -t somecommand
    Then you will be required to press enter to close the terminal, probably not what you're looking for but I can't see your script so I am left to postulation.

    Actually, since I'm just making random guesses, your issue is probably that you arent making use of & or && correctly.

    Okay that's all I have for psychic solutions today.
    clear && echo paste url and press enter; read paste; (youtube-dl $paste) | zenity --progress --title="" --text "Downloading, please wait" --auto-close --pulsate && ans=$(zenity --file-selection); gnome-terminal -x mplayer "$ans"

  4. #4
    Join Date
    Jan 2007
    Location
    Location: Location:
    Beans
    1,246
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Launch 10 for loops in 10 gnome-terminals

    This thread could be a pretty fun game, please move to Cafe.
    clear && echo paste url and press enter; read paste; (youtube-dl $paste) | zenity --progress --title="" --text "Downloading, please wait" --auto-close --pulsate && ans=$(zenity --file-selection); gnome-terminal -x mplayer "$ans"

  5. #5
    Join Date
    May 2012
    Location
    ザ・ワ&
    Beans
    152
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Launch 10 for loops in 10 gnome-terminals

    Well the scripts are pretty simple themselves, I just want a "master script" that runs all 10 simultaneously.

    For examples sake, each script is more or less the same, just the for loop has staggered numbers:
    Code:
    for i in {1..100}; do wget -pk http://foo.com/bar/$i; done
    for i in {101..200}; do wget -pk http://foo.com/bar/$i; done
    for i in {201..300}; do wget -pk http://foo.com/bar/$i; done
    for i in {301..400}; do wget -pk http://foo.com/bar/$i; done
    for i in {401..500}; do wget -pk http://foo.com/bar/$i; done
    ...
    You get the picture, begins a download of the pages http://foo.com/bar/1 - http://foo.com/bar/500 in 5 equal 100 page portions.
    Technomancy
    The old ways are not the only ways. We study the mysteries of laser and circuit, crystal and scanner. Holographic daemons and invocations of equations. These are the tools we employ, and we know many things

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,430
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Launch 10 for loops in 10 gnome-terminals

    Code:
    params=()
    for n in {1..901..100}
    do
      params+=( --tab -e "bash -c 'for(( i=$n; i<$n+100; i++ )); do echo \$i; done; echo job done\!; read;'" )
    done
    printf "%s\n" "${params[@]}"
    gnome-terminal "${params[@]}"
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  7. #7
    Join Date
    Feb 2008
    Beans
    251
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Launch 10 for loops in 10 gnome-terminals

    Quote Originally Posted by ntzrmtthihu777 View Post
    You get the picture, begins a download of the pages http://foo.com/bar/1 - http://foo.com/bar/500 in 5 equal 100 page portions.
    Just beware that by doing this, you might not be making yourself popular with the site's webmaster. You may also fall foul of limits on the numbers of connections or requests/hour that you can make, or just plain old blacklisting of your IP.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •