0

I am using centos

Please help what is SSH commands to do this:

run a command 20 times, break 2 seconds, and repeated again

so like this

// run 20 times
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
//break 2 seconds

// run 20 times
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
wget http://test.com
//break 2 seconds

and loop run it automatically, until i clik ctrl+c to stop it manually

will give rep +1 for all answered

Edited by basketmen

6
Contributors
5
Replies
58
Views
1 Year
Discussion Span
Last Post by JeoSaurus
1

If there is a python interpreter, you can try this perhaps

python -c "$(echo -e "from subprocess import call\nfrom time import sleep\nwhile True:\n for i in range(20): call('wget http://test.com', shell=True)\n sleep(2)")"
3

Hello,

Here is a shell script for what you are requesting but I home you are not really going to do a wget 20 times. If you do you will probably trigger DDOS attack filters that will block your IP address. The "while true " loop will continue to execute (since it is always true ) until you do a <CTRL> C

#!/bin/bash
while true
do
        i=0
        while [ $i -lt 20 ]
        do
                wget http://test.com
                i=$[$i+1]
        done
        sleep 2
done
Votes + Comments
This shell script looks good. The sleep command will pause for 2 seconds.
1

What do you mean by "SSH command"? Are you looking for a way to ssh in to a computer and then run a script that does as you described?

Votes + Comments
good question
1

As per andy1973's question, there is no ssh in the provided code. The wget command has nothing to do with ssh.

Votes + Comments
I think by "SSH" basketmen just means "shell"
0

Seems like @rch1231 has what OP is looking for. Here's an alternative that I like, using the 'seq' command as the counter:

#!/bin/bash
while true; do
    for i in $(seq 1 20); do
        wget http://test.com
    done
    sleep 2
done

I hope this helps!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.