xref: /openbmc/u-boot/tools/netconsole (revision bcb6dd91)
1*bcb6dd91SMike Frysinger#!/bin/sh
2*bcb6dd91SMike Frysinger
3*bcb6dd91SMike Frysingerusage() {
4*bcb6dd91SMike Frysinger	(
5*bcb6dd91SMike Frysinger	echo "Usage: $0 <board IP> [board port]"
6*bcb6dd91SMike Frysinger	echo ""
7*bcb6dd91SMike Frysinger	echo "If port is not specified, '6666' will be used"
8*bcb6dd91SMike Frysinger	[ -z "$*" ] && exit 0
9*bcb6dd91SMike Frysinger	echo ""
10*bcb6dd91SMike Frysinger	echo "ERROR: $*"
11*bcb6dd91SMike Frysinger	exit 1
12*bcb6dd91SMike Frysinger	) 1>&2
13*bcb6dd91SMike Frysinger	exit $?
14*bcb6dd91SMike Frysinger}
15*bcb6dd91SMike Frysinger
16*bcb6dd91SMike Frysingerwhile [ -n "$1" ] ; do
17*bcb6dd91SMike Frysinger	case $1 in
18*bcb6dd91SMike Frysinger		-h|--help) usage;;
19*bcb6dd91SMike Frysinger		--)        break;;
20*bcb6dd91SMike Frysinger		-*)        usage "Invalid option $1";;
21*bcb6dd91SMike Frysinger		*)         break;;
22*bcb6dd91SMike Frysinger	esac
23*bcb6dd91SMike Frysinger	shift
24*bcb6dd91SMike Frysingerdone
25*bcb6dd91SMike Frysinger
26*bcb6dd91SMike Frysingerip=$1
27*bcb6dd91SMike Frysingerport=${2:-6666}
28*bcb6dd91SMike Frysinger
29*bcb6dd91SMike Frysingerif [ -z "${ip}" ] || [ -n "$3" ] ; then
30*bcb6dd91SMike Frysinger	usage "Invalid number of arguments"
31*bcb6dd91SMike Frysingerfi
32*bcb6dd91SMike Frysinger
33*bcb6dd91SMike Frysingerfor nc in netcat nc ; do
34*bcb6dd91SMike Frysinger	type ${nc} >/dev/null && break
35*bcb6dd91SMike Frysingerdone
36*bcb6dd91SMike Frysinger
37*bcb6dd91SMike Frysingertrap "stty icanon echo intr ^C" 0 2 3 5 10 13 15
38*bcb6dd91SMike Frysingerecho "NOTE: the interrupt signal (normally ^C) has been remapped to ^T"
39*bcb6dd91SMike Frysinger
40*bcb6dd91SMike Frysingerstty -icanon -echo intr ^T
41*bcb6dd91SMike Frysinger${nc} -u -l -p ${port} < /dev/null &
42*bcb6dd91SMike Frysingerexec ${nc} -u ${ip} ${port}
43