eb2a2ebd6c39a26c369154f45f7dc62783f3f6c0
[freeradius.git] / src / main / radtest.in
1 #! /bin/sh
2 #
3 # radtest       Emulate the user interface of the old
4 #               radtest that used to be part of cistron-radius.
5 #
6 # Version:      $Id$
7 #
8
9 prefix="@prefix@"
10 exec_prefix="@exec_prefix@"
11 bindir="@bindir@"
12
13 usage() {
14         echo "Usage: radtest user passwd radius-server nas-port-id secret [ppphint] [nasname]" >&2
15         exit 1
16 }
17
18 radclient=$bindir/radclient
19 if [ ! -x "$radclient" ] && [ -x ./radclient ]
20 then
21         radclient=./radclient
22 fi
23
24 if [ "$1" = "-d" ]
25 then
26     DICTIONARY="-d $2"
27     shift;shift
28 else
29     DICTIONARY=""
30 fi
31
32 if [ $# -lt 5 ] || [ $# -gt 7 ]
33 then
34         usage
35 fi
36
37 if [ "$7" ]
38 then
39         nas=$7
40 else
41         nas=`hostname`
42 fi
43
44 (
45         echo "User-Name = \"$1\""
46         echo "Password = \"$2\""
47         echo "NAS-IP-Address = $nas"
48         echo "NAS-Port-Id = $4"
49         if [ "$6" ]
50         then
51                 echo "Framed-Protocol = PPP"
52         fi
53 ) | $radclient $DICTIONARY -x $3 auth $5
54