-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsudo_test.elt
More file actions
executable file
·48 lines (38 loc) · 1.06 KB
/
sudo_test.elt
File metadata and controls
executable file
·48 lines (38 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# make this auto-runnable!
# Little bootstrap bash script to run kick start expect-lite script
# Convert --parms to expect-lite param=value format
PARAMS=`echo $* | /bin/sed -r 's;--([a-z_-]+) ([0-9a-zA-Z_/-]+);\1=\2;g'`
echo $PARAMS
expect-lite r=none c=$0 el=expect-lite d=$PWD $PARAMS
exit $?
# How to use this expect-lite file, Lines that begin with:
# '>' send to remote host, implies "wait for prompt"
# '<' _MUST_ be received from the remote host, or this config script will fail
# # are comment lines, and have no effect
# ; are printable (in stdout) comments, and have no other effect
# @ change the expect timeout value
# ! Embedded Expect commands
# ? If statement, use format ?cond?action::else_action
# For more info see: expect-lite.html
#
# Test of sudo privilages from a script
#
#
#timeout
@5
# sudo password
$pass=secret
# source in native TCL function run_sudo
!source sudo.tcl
>
# run the ID command with sudo privilages
#!run_sudo id $pass
>sudo id
!sudo_pass $pass
+$mygid=gid=[0-9]+\(([a-z]+)\)
<uid=0
>
; == my gid is: $mygid
>
#pau!