#1
|
|||
|
|||
Writing to external file
I'm working on scripting operations on a number of Cisco devices via PerlScript. I want to be able to execute scripts, analyse their output and write comments to an external file. The problem is that I don't seem to be able to write to an external file when I am connected. Here's a sample script which illustrates the problem:
# $language = "PerlScript" # $interface = "1.0" use strict; our $crt; open LOGFILE, ">>mylog.log" or die "Can't open error log"; print LOGFILE "Opened log.\n"; my $text = $crt->Dialog->Prompt("Enter text to write to log:", "Log Data", "", 0); print LOGFILE $text; If I run this script from SecureCRT while not connected to any device, it works fine. Both the "Opened log." statement and whatever I enter in the dialog is written to the file. However, if I run this same script while connected to a remote device (via SSH2 at least - I haven't tested other types of connections), nothing is written to the file. The file is created if it does not exist. The dialog box opens and accepts input. But the file, even after closing the connection and exiting SecureCRT, is empty. I've tried manually flushing the buffer via: my $old_fh = select(LOGFILE); $| = 1; select($old_fh); but to no effect. Suggestions or solutions greatly appreciated. |
#2
|
|||
|
|||
Version info
Forgot to include: I'm using SecureCRT version 4.0.9
|
#3
|
|||
|
|||
No solution
Since no one appears to have a solution or suggestion for this problem, I'd appreciate a small bit of assistance. I'd be grateful if someone using version 4.x could run the sample script both connected and unconnected and confirm the behavior I'm seeing. Second, I'd appreciate someone running version 5.x to see whether the behavior would be corrected by an update to the latest version. Thanks in advance to anyone who can assist.
|
#4
|
|||
|
|||
Hello Dan.
Do you happen to already be logging to the same file that you are trying to log to in in the script? If so, you might try turning off logging first before trying to log to that file. Does that work for you? Thanks JJH |
#5
|
|||
|
|||
Logging file
JJH,
No, this is not the same file that I'm logging to. Apologies if my choice of variable names was confusing. I've tried with logging to a different file turned on and logging turned off. If I'm connected to a remote site, I can't send output to an external file regardless of the status of SecureCRT logging. thanks for the response, though. |
#6
|
|||
|
|||
Hi Dan.
Thanks for the clarification. It looks like we'll need to try to replicate the problem. Which perl engine are you using? Have you tried any other scripting language? JJH |
#7
|
|||
|
|||
Quote:
This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 21 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 816 [255195] provided by ActiveState http://www.ActiveState.com Built Mar 1 2006 18:00:52 Running WindowsXP. Quote:
Last edited by dan.d.jones; 04-11-2006 at 01:18 PM. |
#8
|
|||
|
|||
Well duh!
Color me embarrased.
![]() ![]() |
#9
|
|||
|
|||
Hi Dan.
Thanks for letting me know. I'm glad you got things working - even if you had to go through a little embarrassment to get there. If you have any other questions, please feel free to contact us again. Thanks JJH |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|