Guestshell open file on flash with Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2020 11:43 PM
Hello
How can I open a file on flash from Guestshell with Python?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2020 12:46 AM
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')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2020 04:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2020 03:26 AM
file = open('/bootflash/test.txt','r') print file.read() file.close()
OR
with open('/bootflash/test.txt','r') as file: print file.read()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 10:18 PM
Thank you for the reply.
That works. Flash or Bootflash depends on the device type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 06:34 AM
Please dont forget to rate helpful posts and accept solutions so the post is helpful for other users.
Thank you
