If the above statement returns True, it means the command is executed and next command prompt is displayed on the screen.
Now my problem is this code is working in some machines and the same command is not working on other machine (with same specifications). I debugged the code and found that in those machines the QTP returning the trimmed text which is trimming the last space so "$ " is not the part of returned string. and as the previous command prompts also present on the screen so I can not use only "$" ..
The GetVisibleText method may behave differently in different run sessions depending on the operating system version you are using, service packs you have installed, other installed toolkits, the APIs used in your application, and so on. Therefore, when possible, it is highly recommended to use the GetROProperty method or the Object property to retrieve the value of the text (or equivalent) property from an object in your application instead of using the GetVisibleText method.
[/ QUOTE ]
As far as solution is concerned. Read the GetVisibleText and count the no. of $ in that. Execute the command and count the number of $. It should be one extra then the last one