VanDyke Software

Tips

Index

How To Capture Command Output With ReadString() Using SecureCRT® for Windows®

Note: This tip is for use with SecureCRT for Windows.

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.