VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   file path comparison (

charan314 10-21-2015 09:17 AM

file path comparison

Using the "LogOutputOfSpecificCommand-UseReadString.vbs" script as an example, I have written my script to capture the output and run series of commands based on the result but the comparison is failing although the MsgBox() output shows correct result. Can anyone help me if I did anything wrong?

When I ran MsgBox(szResult1), the output showed me /usr/bin/bksu.

Here is the snippet.


If szResult1 = "/usr/bin/bksu" Then
                crt.Screen.Send "su - produser" & vbCr
                crt.Sleep 1000
                crt.Screen.WaitForString "$ "
                crt.Screen.Send "bash" & vbCr
                MsgBox("None of them work !! Enter manually")
End If

It directly goes to Else statement and prints "None of them work !! Enter manually".

Any help is really appreciated.


rtb 10-21-2015 09:31 AM

Hi Charan,

Thanks for the post.

I ran a quick test, and if the strings that are being compared actual equal each other, then I do enter the If...Then block.

My guess is that the strings you are comparing are subtly different. You might consider using something similar to the following to see if there is anything in the result string that you don't expect:
MsgBox Chr(34) & strResult & Chr(34)
Does this help you find a solution to the problem you are having with your script?

charan314 10-21-2015 10:43 AM

Hi Todd,

I see new line something like this in the dialog box.



I did Trim(szResult1) but that didn't seem to trim the new line character.

rtb 10-21-2015 01:40 PM

Hi Charan,

Since you are waiting for the results of what appears to be sending a command to the remote machine, you are likely actually capturing a CR and an LF.

You might try and use the following to capture the output of the command:
crt.Screen.Send "pwd" & vbcr
strResult = crt.Screen.ReadString vbcrlf & "$"
This is an easy way to strip the newline characters. This will fail if the remote is not sending a CR and an LF. You may want to try replacing "vbcrlf" with "vbcr" or "vblf" if you get a failure.

Does this help you accomplish your goal?

charan314 10-21-2015 02:20 PM

Thank you so much Todd for you advise to use chr(34). I dont know why Trim() didn't work but I used Replace() which solved my problem.


szResult1 = Replace(szResult1, vbCrlf,"")

rtb 10-21-2015 02:38 PM

You are welcome Charan. I am glad I could help.

The Replace() function is a fine way to handle this as well. If you see a failure, just remember that the remote might not be sending both a CR and an LF so you would need to modify your Replace() statement.

All times are GMT -6. The time now is 06:48 AM.