Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Feb 2003 16:17:41 -0800 (PST)
From:      =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net>
To:        Per olof Ljungmark <peo@intersonic.se>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: catch output from sh -xv to a file
Message-ID:  <20030216161258.L70415-100000@atlas.home>
In-Reply-To: <3E500C6F.2030805@intersonic.se>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <pipe stuff to file>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030216161258.L70415-100000>