| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Date: | Fri, 6 Dec 2002 09:47:41 -0800 (PST) |
| From: | Michael A Chase <mchase AT ix DOT netcom DOT com> |
| Subject: | Re: GCC compiler cannot create executables. |
| To: | Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>, cygwin AT cygwin DOT com |
| cc: | Ryan Budge <ryan AT smarthand DOT co DOT za> |
| Message-ID: | <Mahogany-0.64.2-1879-20021206-094741.00@ix.netcom.com> |
| MIME-Version: | 1.0 |
| references: | <Pine DOT GSO DOT 4 DOT 44 DOT 0212061204330 DOT 29289-100000 AT slinky DOT cs DOT nyu DOT edu> |
| in-reply-to: | <Pine.GSO.4.44.0212061204330.29289-100000@slinky.cs.nyu.edu> |
| fcc: | SentMail |
| Reply-To: | Michael A Chase <mchase AT ix DOT netcom DOT com> |
--279716865-1681692777-1039196863=:1879
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Disposition: INLINE
On Fri, 6 Dec 2002 12:05:24 -0500 (EST) Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu> wrote:
> FWIW, there's also apparently a cygwin port of 'script':
> http://cygwin.com/ml/cygwin/2002-09/msg01371.html
It's also easy to redirect STDOUT and STDERR to a file. I found myself
doing it often enough that I wrote a script to do it for me. It needs a
log/ directory in the current directory or one of its parents.
--279716865-1681692777-1039196863=:1879
Content-Type: TEXT/PLAIN; NAME="/home/mchase/bin/tlog.sh"; CHARSET=US-ASCII
Content-Disposition: INLINE; FILENAME="tlog.sh"
#!/bin/bash
# Find nearest log directory and tee log command output to a file there
# set -xv
log=""
usage() {
if [ 1 -le $# ]; then $rc="$1"; shift; else rc=0; fi
basename=$(basename "$0")
msg=\
"Send stdout and stderr to a log file
If no log file is specified, search for the nearest log/ directory in ./,
../, ../../ until / is reached and generate a file name based on the command
name and the current date and time.
syntax: $basename [opt] cmd [arg]...
Opt:
-l log = Log file ($log)
Arg:
cmd = Command to execute
arg = Options and arguments to cmd"
while [ 1 -le $# ]; do
if [ 0 = "$rc" ]; then echo "$1"; else echo "$1" >&2; fi
shift
done
if [ 0 = "$rc" ]; then echo "$msg"; else echo "$msg" >&2; fi
exit $rc
}
while getopts ':hl:' OPT
do
case $OPT in
l) log="$OPTARG" ;;
h) usage 0 ;;
*) usage 1 "Invalid Option: -$OPTARG" ;;
esac
done
if [ 1 -lt $OPTIND ]; then shift $(expr $OPTIND - 1); fi
# Make sure there is a command name
if [ 1 -gt $# ]; then
echo "No command name"
exit 1
fi
cmd=$(basename "$1")
# Find log directory and build log file name
if [ -z "$log" ]; then
logbase="$PWD"
while :; do
if [ "/" = "$logbase" ]; then
echo "Log directory not found under $PWD"
exit 1
fi
if [ -d "$logbase/log" -a -w "$logbase/log" ]; then break; fi
logbase=`dirname "$logbase"`
done
dt=$(date +%y%m%d_%H%M)
log="$logbase/log/$cmd-$dt.log"
fi
echo "Log file: $log"
touch "$log"
echo "Dir: '$PWD'" >> "$log"
echo "Command:" "$@" >> "$log"
"$@" 2>&1 | tee -a "$log"
echo "Log file: $log"
--279716865-1681692777-1039196863=:1879
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Disposition: INLINE
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
--279716865-1681692777-1039196863=:1879
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--279716865-1681692777-1039196863=:1879--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |