#1
|
|||
|
|||
file path comparison
Hello,
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. Code:
If szResult1 = "/usr/bin/bksu" Then crt.Screen.Send "su - produser" & vbCr crt.Sleep 1000 crt.Screen.WaitForString "$ " crt.Screen.Send "bash" & vbCr crt.Screen.Clear Else MsgBox("None of them work !! Enter manually") End If Any help is really appreciated. Thanks, Charan |
#2
|
|||
|
|||
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? |
#3
|
|||
|
|||
Hi Todd,
I see new line something like this in the dialog box. Code:
"/usr/bin/bksu " |
#4
|
|||
|
|||
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" & vbcrThis 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? |
#5
|
|||
|
|||
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.
Code:
szResult1 = Replace(szResult1, vbCrlf,"") |
#6
|
|||
|
|||
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. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|