From owner-freebsd-questions@FreeBSD.ORG Tue Jan 15 17:47:27 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7A8CBC3C for ; Tue, 15 Jan 2013 17:47:27 +0000 (UTC) (envelope-from nvass@gmx.com) Received: from mout.gmx.net (mout.gmx.net [74.208.4.201]) by mx1.freebsd.org (Postfix) with ESMTP id 16E3EB07 for ; Tue, 15 Jan 2013 17:47:27 +0000 (UTC) Received: from mailout-us.gmx.com ([172.19.198.46]) by mrigmx.server.lan (mrigmxus001) with ESMTP (Nemesis) id 0Ln7wP-1TIFKm17Ij-00hR57 for ; Tue, 15 Jan 2013 18:42:17 +0100 Received: (qmail invoked by alias); 15 Jan 2013 17:42:16 -0000 Received: from 188.4.180.247.dsl.dyn.forthnet.gr (EHLO [192.168.1.66]) [188.4.180.247] by mail.gmx.com (mp-us006) with SMTP; 15 Jan 2013 12:42:16 -0500 X-Authenticated: #46156728 X-Provags-ID: V01U2FsdGVkX18kj0Q8N5sk+68h0iDmR4HyD9C0HDvw4p13yuRama 9X/OV4BPzTZeIJ Message-ID: <50F594E9.7000606@gmx.com> Date: Tue, 15 Jan 2013 19:42:01 +0200 From: Nikos Vassiliadis User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Free BSD Questions list Subject: assigning values to variables in the background Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2013 17:47:27 -0000 Hi, A bit of an OT question. I am writing a bourne shell script that collects data from a router. Since netstat & vmstat can run for a numbers of iterations I thought I would use just that: stats() ( nstats=`netstat -I ng0 -q 1 60 | tail -1` & rawdata=`vmstat -c 2 60 | tail -1` wait ... The logic was: 1. run the first process in the bg 2. run the second process 3. wait to make sure the first process has finished 4. continue further It makes perfect sense why this doesn't work. Both commands run in the foreground. I am going to split the time between netstat and vmstat. So, it will be 30 seconds of netstat and 30 seconds of vmstat. But I am still interested/curious how one should go for this using the shell. So, can this be done without files? Any thoughts? Thanks, Nikos