The Prompt property allows wodSSH to determine if server has
shown command prompt - meaning last executed command have finished, so that new commands can be
executed. wodSSH cannot be smart about determining when server shows
command prompt - so you have to specify it here. Since version
2.3.0.0 wodSSH also allows regular expressions to be used when
command prompt is searched in received data.
If you have more than one command to execute on the remote
server, you will find this feature handy. If you set it up
property, wodSSH will fire a PromptReceived
event each time it recognizes the command prompt sequence.
For example:
try to connect to your server. After the connection is
established, you will receive something like this:
telnet some.host.com
Trying some.host.com...
Connected to 192.168.1.10.
Escape character is '^]'.
somehost login: joe
Password:
Linux 2.4.5.
Last login: Sat Jan 26 2002 on pts/0 from mainframe.
No mail.
joe@somehost:~$
note here that the sequence 'joe@somehost:'
represents the command prompt string that will be returned by the
server each time it expects a new command. To be even more
certain, you can add CRLF sequence before it.
If you set Prompt = "joe@somehost:" then
each time wodSSH finds this sequence it will fire the
PromptReceived event. Here you can execute a new command,
and wait for it's output.
If Prompt property is set, the command prompt string you
entered will not be provided through the Received
event - which means you don't have to 'cut it
out' of the command output.
As mentioned above, you can provide regular expression to be
searched in received data instead of exact value. You should prepend
your Prompt property with regex: text so wodSSH knows you are
using regular expression. For example, you can use it like this:
- Ssh.HostName = "some.host.com"
Ssh.Login = "joe"
Ssh.Password = "secretpass"
Ssh.Protocol = SSHAuto
Ssh.Prompt = "regex:[\$%#>] $"
Ssh.Connect
above regular expression will match when:
- $, %, #, or > found
- space
- end of line
typically, our previous sample joe@somehost:~$<SPACE>
does match above regex. But, hey, feel free to use something more
complex such as:
-
- Debug.Print
Ssh1.Execute("cd /tmp" & VbLf,
"regex:[a-zA-z0-9]+@[a-zA-z0-9]+:[a-zA-z0-9~/]+[\$%#>]
$")
-
- or using extended PERL syntax
-
- Debug.Print
Ssh1.Execute("cd /tmp" & VbLf,
"regex:\w+@\w+:\S+\$
$")
just don't forget to put 'regex:' text in front of regular
expression, otherwise wodSSH will search for exact match of
specified pattern. PCRE (www.pcre.org)
library is used for regex support.