SUPPORT > TIPS
Send us a question or comment

 

Send us your tip idea

How To Capture Command Output With ReadString()

Have you ever wanted to run a command from a script and log just the output from those commands? You can do this using ReadString(), a method of the Screen object which gives access to data as it comes from the remote system. The script example, LogOutputOfSpecificCommand-UseReadString, executes a set of shell commands, and logs the results to a file.

ReadString() operates in a manner similar to the WaitForString() method, returning all data received until a specified string is detected. By default, the data captured includes escape sequences, but there is a way to exclude these sequences by setting the IgnoreEscape property to True as shown in the example script code.

The example script assumes that SecureCRT is already connected to the remote device; otherwise the script exits with an error message. The script comments suggest how to add the connection sequence if needed.

If you have any questions about ReadString() or Screen object properties and methods, contact VanDyke Software Support.


Tell us what you think. Did you find this tip useful? Do you have a question you'd like us to answer? Send your comments and questions to VanDyke Software Support.

1.  Read or download one of our secure solutions white papers. 2.  Download a free
30-day evaluation copy of our products.
3.  Let us help define the right Secure Shell solution for your company. 4.  Subscribe to our monthly newsletter for tips, solutions ideas, and product news.