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

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)")"

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
commented: This shell script looks good. The sleep command will pause for 2 seconds. +0

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?

commented: good question +13

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

commented: I think by "SSH" basketmen just means "shell" +5

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.