Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Output to File

Status
Not open for further replies.

craigdthomas1

Technical User
Aug 18, 2004
4
US
Hello All!!

I have a script that telnets into several machine and executes a few commands. One of the commands retrieves a list of all the users for that machine. The script works fine.

I would like to know if it is possible to have the output directed to a text file.

Any help would be greatly apprecaited!!!

Thanks
Craig
 
Probably the easiest thing to do is to use the capture ON and capture OFF commands to open and close a capture file to send the output of the command to a file. You can use the various set capture commands (see the ASPECT help file for more information) to set the filename, location, and so forth. You might also want to issue a clear command before opening the capture file so that the other information on the screen does not appear in the text file.


aspect@aspectscripting.com
 
As always ... Thanks Knob for the prompt response!!

I noticed the capture function generates a ".cap" file. My plan is to email the text file to other users. I don't know if the ".cap" file will open for the users that do not have Procomm loaded.

I found a previous thread, but I could not fully understand what was going on, as I am rather new at this.

In the article written on 7/27/2004 (How to Format Data in capture loop) ... In that reply Knob responds ..
"Is there any reason you are using a capture file rather than grabbing the incoming data from the port and writing that to a text file you have opened? "

I could understand the idea, but some of the terms took me off course. I did not know what you meant by taking data from the port(What is a port?) and as the article went into more detail the more I went off course.

Are you aware of any other threads or sample scripts that go into a little more details around writing text to a file that I have opened.



Once again Thanks,
Craig
 
The default extension for a capture file is .cap but you can specify a different filename using the set capture file command.

What I was discussing in the other thread was using the rget command to read data directly from the modem instead of Procomm's scrollback buffer. This would let you have a little more flexibility in what ends up in the final file, since your script would be reading string by string and writing only the data you wanted to to the text file. However, it's a bit more intensive and any text you read using rget does not appear in the Procomm window (this may or may not be an issue for you).

If you look at the last message in the thread you mentioned, I have a quick example that shows how to append a string to a text file. I'm not aware of anything more general. I do have a couple examples showing how to read from and write to text files, but for the most part the reading and writing is the same, it's just how the data is manipulated in those examples after it has been accessed.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top