From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlpGa-0003lZ-9D for qemu-devel@nongnu.org; Fri, 13 Jan 2012 17:06:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlpGX-0007xn-Od for qemu-devel@nongnu.org; Fri, 13 Jan 2012 17:06:32 -0500 Received: from e36.co.us.ibm.com ([32.97.110.154]:42145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlpGX-0007xd-Fx for qemu-devel@nongnu.org; Fri, 13 Jan 2012 17:06:29 -0500 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jan 2012 15:06:28 -0700 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0DM69T8026446 for ; Fri, 13 Jan 2012 15:06:09 -0700 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0DM69gw014531 for ; Fri, 13 Jan 2012 15:06:09 -0700 From: Ryan Harper Date: Fri, 13 Jan 2012 16:05:18 -0600 Message-Id: <1326492321-13540-2-git-send-email-ryanh@us.ibm.com> In-Reply-To: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> References: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> Subject: [Qemu-devel] [PATCH 1/4] update get_file_size to not throw error on non-existant files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ryan Harper In some cases, when qemu is just starting up the logfile hasn't yet been created and will throw an error message into the output: ls: cannot access .tmp-3070/logfile-3070.log: No such file or directory if we check to see if the file is readable first then we know the file is present and we can extract the size. Signed-off-by: Ryan Harper --- qemu-test | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qemu-test b/qemu-test index c6ea595..cd102a7 100755 --- a/qemu-test +++ b/qemu-test @@ -54,9 +54,10 @@ checkpid() { } get_file_size() { - ls -al $1 | cut -f5 -d' ' 2>/dev/null - if test $? != 0; then - echo 0 + if test -r "${1}" ; then + ls -al $1 | cut -f5 -d' ' + else + echo 0 fi } -- 1.7.6