summaryrefslogtreecommitdiff
path: root/testsuite/lib/smbclient.exp
blob: dc55d72139cbfdd7bc24077a446577a602458de0 (plain)
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
46
47
48
49
50
51
52
53
54
#
# Utilities for driving smbclient
#

# Variables

set smb_prompt "smb: \\\\>"

# Spawn smbclient and wait for a prompt

proc spawn_smbclient { args } {
    set result 0
    global smb_prompt
    global spawn_id

    # Spawn smbclient

    spawn smbclient [lindex $args 0] [lindex $args 1] [lindex $args 2] \
	    [lindex $args 3] [lindex $args 4] [lindex $args 5] \
	    [lindex $args 6]

    # Wait for prompt

    expect {
	$smb_prompt   { set result 1 }
	timeout       { perror "timed out spawning smbclient" }
	eof           { perror "end of file spawning smbclient" }
    }

    return $result
}

# Run a command and wait for a prompt

proc do_smbclient { args } {
    set action [lindex $args 0]
    set description [lindex $args 1]
    global smb_prompt

    # Send command

    verbose $action

    send $action

    expect {
	$smb_prompt     {}
	timeout         { perror "timed out $description"; return -1}
	eof             { perror "end of file $description"; return -1 }
    }

    verbose $expect_out(buffer)
    return $expect_out(buffer)
}