mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
b0953a3595
(This used to be commit 6d50bb36a68c34c5fea1193fd6f170160e16e76f)
53 lines
974 B
Plaintext
53 lines
974 B
Plaintext
#
|
|
# 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]
|
|
|
|
# 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)
|
|
}
|