Special Characters

To ensure that the correct meaning is transmitted to the remote system when using the rush command, the use of special characters and shell variables needs to be considered.

Special Characters and Shell Variables

Normally, the local shell recognises and interprets special shell command characters for local execution. For example the command:

rush HOST2 cat file1 > file2

copies file1 from HOST2 to file2 on the local system.

A quote or escape character causes the local shell to ignore special command characters and pass them to the remote system. There are three ways to quote or escape special characters:

  1. Precede each special character with a backslash. For example:

    rush HOST2 cat myfile \> newfile

    copies myfile on HOST2 to newfile on HOST2.

  2. Place single quotes around the special command characters, or any arguments to them. All special characters within the quotes are ignored by the local shell. For example:

    rush HOST2 cat myfile '>' newfile

    or

    rush HOST2 cat 'myfile > newfile'
  3. Place double quotes around special command characters, or any arguments to them. This has the same effect as the single quotes except that within double quotes any shell variables are interpreted by the local shell. For example in:

    rush HOST2 cat "$file > file2"

    the local shell does the substitution for the variable $file but

    rush HOST2 cat '$file > file2'

    passes $file to the remote shell for substitution.

    Note

    With both command lines the filename contained in the $file variable is taken to be a file residing on the remote system, regardless of which system substitutes the variable.

Filename Expansion

The same principles apply to special command characters used for filename expansion.

Imagine that there are three files on the remote system: file1, file2 and file3, which you wish to print to the local terminal. There are three files on the local system called filea, fileb and filec. The command:

rush HOST2 cat file*

attempts to send the named files from HOST2 to the local terminal. However, as the asterisk in the file name is not quoted or escaped, the local shell performs the filename expansion, passing the filenames (filea, fileb, filec) across the network to HOST2. These are not the files you intended to print. In order to achieve your objective you must quote the asterisk as follows:

rush HOST2 cat 'file*'

The filename expansion will be performed by the remote shell to match the files file1, file2 and file3 on HOST2.