cp command

Duplicates one or more remote files.



cp <file> [ <file2> ... ] [ <directory>/ ][ <newname> ]


Destination directory or newname or both must be specified. Destination directory must end with slash. Operation mask can be used instead of new name. Filename can be replaced with wildcard to select multiple files.

Effective options: failonnomatch

XML log element: cp


cp index.html backup/
cp index.html *.bak
cp index.html public_html/about.*
cp public_html/index.html public_html/about.html /home/martin/*.bak


Converting to .NET Assembly

When converting script to .NET Assembly, map cp command to Session.DuplicateFile method.

Parameters mapping: Command parameter file maps to method parameter sourcePath. When multiple source file parameters are used, you need to call Session.DuplicateFile multiple times. Command parameter directory/newname maps to method parameter targetPath. You have to convert relative paths to absolute paths.

For example, following script snippet:

cd /home/martinp
cp public_html/index.html public_html/about.html *.bak

maps to following PowerShell code:

$session.DuplicateFile("/home/martinp/public_html/index.html", "/home/martinp/*.bak")
$session.DuplicateFile("/home/martinp/public_html/about.html", "/home/martinp/*.bak")

Last modified: by martin