give the timeout a default value. fixes everything that uses shell_command_token_* with one arg

git-svn-id: file:///home/svn/framework3/trunk@11800 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2011-02-23 01:33:39 +00:00
parent aa859e2f68
commit f647088fba
1 changed files with 8 additions and 8 deletions

View File

@ -41,7 +41,7 @@ module SingleCommandShell
#
# Read data until we find the token
#
def shell_read_until_token(token, wanted_idx = 0, timeout = 10)
def shell_read_until_token(token, wanted_idx=0, timeout=10)
if (wanted_idx == 0)
parts_needed = 2
else
@ -75,11 +75,11 @@ module SingleCommandShell
nil
end
def shell_command_token(cmd,timeout = 10)
def shell_command_token(cmd, timeout=10)
if platform =~ /win/
output = shell_command_token_win32(cmd,timeout)
output = shell_command_token_win32(cmd, timeout)
else
output = shell_command_token_unix(cmd,timeout)
output = shell_command_token_unix(cmd, timeout)
end
output
end
@ -88,7 +88,7 @@ module SingleCommandShell
# Explicitly run a single command and return the output.
# This version uses a marker to denote the end of data (instead of a timeout).
#
def shell_command_token_unix(cmd,timeout)
def shell_command_token_unix(cmd, timeout=10)
# read any pending data
buf = shell_read(-1, 0.01)
token = ::Rex::Text.rand_text_alpha(32)
@ -96,14 +96,14 @@ module SingleCommandShell
# Send the command to the session's stdin.
# NOTE: if the session echoes input we don't need to echo the token twice.
shell_write(cmd + ";echo #{token}\n")
shell_read_until_token(token,0,timeout)
shell_read_until_token(token, 0, timeout)
end
#
# Explicitly run a single command and return the output.
# This version uses a marker to denote the end of data (instead of a timeout).
#
def shell_command_token_win32(cmd,timeout)
def shell_command_token_win32(cmd, timeout=10)
# read any pending data
buf = shell_read(-1, 0.01)
token = ::Rex::Text.rand_text_alpha(32)
@ -111,7 +111,7 @@ module SingleCommandShell
# Send the command to the session's stdin.
# NOTE: if the session echoes input we don't need to echo the token twice.
shell_write(cmd + "&echo #{token}\n")
shell_read_until_token(token, 1,timeout)
shell_read_until_token(token, 1, timeout)
end