LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2011, 12:36 AM   #1
keller999
LQ Newbie
 
Registered: Apr 2011
Posts: 1

Rep: Reputation: 0
Expect/TCL Logging -- any way to create a clean log file?


I've written an Expect script that assists with change management on Cisco devices. The script creates log files for pre-change, the change itself, and post-change. Each log and its commands is triggered by a ! command.

For example:

Code:
./dochange.exp hostname
<script spawns bash, user SSHes to hostname>

!PRE
<script runs some show commands and logs to pre.log>

int f0/0
shut
<the above is logged to change.log>

!POST
<script runs some show command and logs to post.log>
All of this works fine. My big hair-pulling hiccup is that the resulting log files are filled with raw backspace characters!

I am using log_file to log the output from the script. I stop and restart logging with a new file when needed. However, the log files are pretty much unusable.

After doing some research, it looks like log_file sends output to the file in real-time, unbuffered. When I hit a key, it's immediately sent to the log. What I would like is for only the resulting string to go to the log.

If I start to type 'reload' and instead type 'show run', I don't want 'reload' to be listed in the log at all.

Anyone know if this is possible? Any help would be greatly appreciated!

Thanks,

Keller
 
Old 04-18-2011, 12:27 PM   #2
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
You could always pipe it through sed.
Code:
sed ':t;s/[^\b]\b//g;t t'
should do the trick.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
expect (Tcl) question kristof_v Programming 2 01-24-2013 05:32 AM
Clean Up Log - Search for Pattern in Log file and Output result bridrod Linux - Newbie 10 01-05-2010 09:49 AM
tcl/expect stdout redirected to file stops (possibly due to a "@" in exp_send) cejennings_cr Programming 1 07-08-2009 06:01 PM
TCL e EXPECT gustavolinux Programming 1 10-17-2008 09:03 AM
How i can Clean up the log file of proxy? AZIMBD03 Red Hat 4 10-10-2003 08:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration