cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
685
Views
5
Helpful
5
Replies
nathy1984
Beginner

Guestshell open file on flash with Python

Hello

 

How can I open a file on flash from Guestshell with Python?

Thanks.

5 REPLIES 5
ngkin2010
Enthusiast

Hi,

As I remember, the absolute path of flash drive is '/flash' in guestshell. Make sure you got at least 'read' file permission, and you could open the file by Python.

fd = open('/flash/filename','r')

It should be '/bootflash' instead of '/flash' as mentioned by @omz
omz
VIP Collaborator VIP Collaborator
VIP Collaborator

file = open('/bootflash/test.txt','r')
print file.read()
file.close()

OR
with open('/bootflash/test.txt','r') as file: print file.read()

Thank you for the reply.

That works. Flash or Bootflash depends on the device type.

omz
VIP Collaborator VIP Collaborator
VIP Collaborator

Please dont forget to rate helpful posts and accept solutions so the post is helpful for other users.

Thank you  

Content for Community-Ad

This widget could not be displayed.