From owner-freebsd-questions Sun Feb 16 16:17:45 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A542137B401 for ; Sun, 16 Feb 2003 16:17:44 -0800 (PST) Received: from mta5.snfc21.pbi.net (mta5.snfc21.pbi.net [206.13.28.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2075643F75 for ; Sun, 16 Feb 2003 16:17:42 -0800 (PST) (envelope-from mbsd@pacbell.net) Received: from atlas ([64.165.200.209]) by mta5.snfc21.pbi.net (iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 2002)) with ESMTP id <0HAF00960FHH1A@mta5.snfc21.pbi.net> for freebsd-questions@freebsd.org; Sun, 16 Feb 2003 16:17:41 -0800 (PST) Date: Sun, 16 Feb 2003 16:17:41 -0800 (PST) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= Subject: Re: catch output from sh -xv to a file In-reply-to: <3E500C6F.2030805@intersonic.se> X-X-Sender: mikko@atlas.home To: Per olof Ljungmark Cc: freebsd-questions Message-id: <20030216161258.L70415-100000@atlas.home> MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 16 Feb 2003, Per olof Ljungmark wrote: > Need advice on how to modify first line of shell script so that script > can run normally (as called from another program, not from the command > line) and write debugging output to a file like: Short answer: you can't. Not if you absolutely want to change just the first line, and not really if you want the script to run "normally", as you would have to divert stderr. > #!/bin/sh > echo DEFANGED.1007 > exit > #!/bin/sh -xv Try: #!/bin/sh exec 2> /tmp/logfile; set -xv # rest of script here... Should work, except for the script being unable to print stuff to stderr. There is also the possibility that I'm totally missing your point... :) $.02, /Mikko To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message