File Handling Howto

Introduction

This page aims to explain how files are handled, both locally and how files are moved to external media and network locations.

In this Howto configuration files are used as an example for other types of files see this page.

In all examples below it is assumed that the user has entered the configuration file context by executing:

example:/#> file cfg
example:/file/cfg/#>

General

All commands except import and export support TAB-completion of command arguments. For file arguments, actual present files are shown as well as symbolic names like running-config and startup-config.

In the top level of the CLI commands exist for specific file types.

  • follow for log files
  • diff for configuration files
  • copy for configuration files

Viewing a file

To view a file the show command is used. This command is context aware meaning that is has specific features for different contexts. In this example of configuration files the show command is aware that the configuration files are json files.

In this example a subsection of the running-config is shown.

example:/file/cfg/#> show running-config meta vendor 
Westermo

Whereas the full configuration can be viewed with:

example:/file/cfg/#> show running-config

A configuration file on external media can be viewed with:

example:/file/cfg/#> show media external example.cfg

Erasing a file

Erasing file on internal media:

example:/file/cfg/#> erase media internal example.cfg

Erasing file on external media:

example:/file/cfg/#> erase media external example.cfg

Erasing file on boot media:

example:/file/cfg/#> erase example.cfg/b>

Copy file to and from internal and external media

If an external media is mounted files can be copied from and to it.

Copying to internal media:

example:/file/cfg/#> copy running-config media internal example.cfg

Copying to external media:

example:/file/cfg/#> copy running-config media external example.cfg

Copying from external media to internal media:

example:/file/cfg/#> copy media external example.cfg media internal example.cfg

Copy file to and from network device

Exporting file to a network location via ftp:

example:/file/cfg/#> export example.cfg proto ftp user test_user password test_password 192.0.2.1

Exporting file to a network location via scp:

example:/file/cfg/#> export example.cfg proto scp user test_user password test_password 192.0.2.1

Importing file from a network location using ftp

example:/file/cfg/#> import proto ftp user test_user password test_password 192.0.2.1 example_remote.cfg example.cfg