nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #! /bin/bash |
2 | # source: readline-test.sh |
||
3 | # Copyright Gerhard Rieger 2003-2008 |
||
4 | # Published under the GNU General Public License V.2, see file COPYING |
||
5 | |||
6 | # script that simulates a simple program with authentication. |
||
7 | # is just for testing the readline features |
||
8 | # perform the test with something like: |
||
9 | # ./socat readline,history=$HOME/.history,noecho='^Password: ' system:./readline-test.sh,pty,setsid,ctty,stderr,sigint,sigquit,echo=0,raw |
||
10 | |||
11 | |||
12 | BANNER='readline feature test program' |
||
13 | USERPROMPT='Authentication required\nUsername: ' |
||
14 | PWDPROMPT='Password: ' |
||
15 | PROMPT='prog> ' |
||
16 | |||
17 | # degenerated user database |
||
18 | CREDUSER="user" |
||
19 | CREDPASS="password" |
||
20 | |||
21 | if [ $(echo "x\c") = "x" ]; then ECHO="echo" |
||
22 | elif [ $(echo -e "x\c") = "x" ]; then ECHO="echo -e" |
||
23 | fi |
||
24 | |||
25 | #trap "$ECHO $0 got SIGINT" INT |
||
26 | trap "$ECHO $0 got SIGINT" INT |
||
27 | trap "$ECHO $0 got SIGQUIT" QUIT |
||
28 | |||
29 | # print banner |
||
30 | $ECHO "$BANNER" |
||
31 | |||
32 | # on (some) ksh read -p does not mean prompt |
||
33 | $ECHO "$USERPROMPT\c"; read -r USERNAME |
||
34 | $ECHO "$PWDPROMPT\c"; read -rs PASSWORD |
||
35 | $ECHO |
||
36 | |||
37 | if [ "$USERNAME" != "$CREDUSER" -o "$PASSWORD" != "$CREDPASS" ]; then |
||
38 | $ECHO "Authentication failed" >&2 |
||
39 | exit -1 |
||
40 | fi |
||
41 | |||
42 | while $ECHO "$PROMPT\c"; read -r COMMAND; do |
||
43 | if [ "$COMMAND" = "exit" ]; then |
||
44 | break; |
||
45 | fi |
||
46 | $ECHO "executing $COMMAND" |
||
47 | done |