cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3939
Views
0
Helpful
3
Replies

Unable to write/create a file through TCL command

ahuamancayo
Level 1
Level 1

Hello Everyone!

 

I'm trying to create/write a file in bootflash: through a script and It fails... I tried to run the command directly in the TCLSH interpreter but I get this message:

 

N7K-CORE# tclsh
N7K-CORE-tcl# open bootflash:///clock.log "a+"
couldn't open "bootflash:///clock.log": no such file or directory
N7K-CORE-tcl# open bootflash://clock.log "a+"
couldn't open "bootflash://clock.log": no such file or directory
N7K-CORE-tcl# open bootflash:/clock.log "a+"
couldn't open "bootflash:/clock.log": no such file or directory

N7K-CORE-tcl# dir
4096 Apr 28 17:32:52 2021 Scripts/
0 Apr 28 17:30:22 2021 clock.log
0 Apr 28 17:29:44 2021 infoTAC.log
664 Sep 29 15:22:10 2014 vlan.dat

Usage for bootflash://
1281138688 bytes used
535347200 bytes free
1816485888 bytes total
N7K-CORE-tcl# exit

Any thoughts?

 

Thanks in advance.

Adrian

@TCL @nexus @nx-os

3 Replies 3

balaji.bandi
Hall of Fame
Hall of Fame

Can you able to read the file :  (it is 0 size ?)

 

show file  bootflash://clock.log

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Hi, yeah, it's empty beacause the original message was like "there's not such file", so I thought maybe it need the file to already exists so I created empty...

Now, I've just uploaded a new file with some content and yes I can read it:

 

N7K-CORE# show file bootflash:clock.log
Sample Text
working on it...
N7K-CORE# 

I tried the same tests and I aaded the last line, so I thought it works without slashes: 

 

 

N7K-CORE-tcl# open bootflash:///clock.log "a+"
couldn't open "bootflash:///clock.log": no such file or directory
N7K-CORE-tcl# open bootflash://clock.log "a+"
couldn't open "bootflash://clock.log": no such file or directory
N7K-CORE-tcl# open bootflash:/clock.log "a+"
couldn't open "bootflash:/clock.log": no such file or directory
N7K-CORE-tcl# open bootflash:clock.log "a+"
file37
N7K-CORE-tcl# 

I tried again writing in the file without the slashes but It's waiting for an integer... I tried the integer and it didn't write anything:

 

 

N7K-CORE-tcl# open bootflash:clock.log "a+" {
> "insert new line here"
> }
expected integer but got "
"insert new line here"
"
N7K-CORE-tcl# open bootflash:clock.log "a+" {
> 256
> }
file38
N7K-CORE-tcl# exit
N7K-CORE# show file bootflash:clock.log
Sample Text
working on it...
N7K-CORE1# 

 

Any other idea? Anyway, thanks for your time

mario.jost
Level 3
Level 3

Hey ahuamancayo

Did you solve your issue? I am at the same situation and am clueless. Since the different departments of cisco dont talk to eachother we cannot manage our nexus switche with prime/DNAC so we are looking for a way to periodically upload our running config as a sanitized version (all PWs removed) to a central server. So I wrote a TCL script for it which works great on IOS-XE but not on NX-OS. It seems, it cant write into a file on the bootflash, just as you described. First i tested creating a file:

 

swRZ112# tclsh 
swRZ112-tcl# set writefile [open "bootflash:example.txt" "a+"]
file37
swRZ112-tcl# puts $writefile "dunno"
swRZ112-tcl# close $writefile
swRZ112-tcl# tclquit
Exiting Tcl
swRZ112# dir bootflash: | include txt

 But the file does not exist. Then i created a file and wanted to add something with TCL:

swRZ112# show version | include uptime
Kernel uptime is 178 day(s), 2 hour(s), 19 minute(s), 41 second(s)
swRZ112# show version | include uptime > bootflash:txtfile.txt
swRZ112# tclsh
swRZ112-tcl# set write2file [open "bootflash:txtfile.txt" "a+"]
file37
swRZ112-tcl# puts $write2file "exampletext"
swRZ112-tcl# close $write2file
swRZ112-tcl# tclquit
Exiting Tcl
swRZ112# show file bootflash:txtfile.txt
Kernel uptime is 178 day(s), 2 hour(s), 20 minute(s), 7 second(s)

But sadly, this does not work either. Did you find a solution to your problem? I read thru all Cisco documentation regarding NX-OS and TCL but it is very sparse and there is no file handling bit. Thanks for your answer.