cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
366
Views
5
Helpful
5
Replies
Highlighted
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
Highlighted
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')
Highlighted

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

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

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

Thank you for the reply.

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

Highlighted

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

Thank you  

This widget could not be displayed.