Register
It is currently Fri Jul 25, 2014 2:39 pm

Parallel Ping


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Wed Mar 17, 2010 12:03 am   

Joined: Tue Mar 16, 2010 7:16 pm
Posts: 3
I know this isn't necessarily the best way to do things, but I'm in the process of learning Bash scripting and I'm trying to implement some sort of concurrency. Is it possible to send tasks to the background and then have them update a record (an array, perhaps) in the main script when they're done?

Here's an example of what I've tried and failed with so far:

Code:
arr=({0..9})

for i in ${!arr[*]}
do
    jobs=0
    while [[ $jobs -lt 2 ]]
    do

        $arr[$i]=$(ping -c 1 localhost &)
        let "jobs++"
    done
    wait
done

Would it make any difference in terms of "backgroundability" if the task involved piping?


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP