免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3725 | 回复: 0
打印 上一主题 下一主题

rcp 拷贝远程主机文件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-06 10:11 |只看该作者 |倒序浏览

例如:
rcp 用户名@远程主机名(ip):目录/文件   本地目录
需要在远程主机此用户的主目录下 .rhosts文件,文件内容为:
远程主机ip   远程主机用户
例如:
133.38.xx.xx  ms
如果不用ip地址用主机名,要在/etc/hosts 下有ip地址与主机名对应关系
/etc/inetd.conf:
  shell     stream   tcp   nowait   root   /usr/lbin/remshd       remshd   
  kshell   stream   tcp   nowait   root   /usr/lbin/remshd   remshd   -K   
保证这个服务启动了。
NAME
      rcp - remote file copy
SYNOPSIS
    Copy Single File:
      rcp [-p] source_file1 dest_file
    Copy Multiple Files:
      rcp [-p] source_file1 [source_file2 ...] dest_dir
    Copy One or More Directory Subtrees:
      rcp [-p] -r source_dir1 [source_dir2 ...] dest_dir
    Copy Files and Directory Subtrees:
      rcp [-p] -r file_or_dir1 [file_or_dir2 ...] dest_dir
DESCRIPTION
      rcp (remote copy) copies files, directory subtrees, or a combination
      of files and directory subtrees from one or more systems to another.
      In many respects, it is very similar to the cp command. (see
cp(1)
.
      The user must have read access to files being copied, and read and
      search (execute) permission on all directories in the directory path.
    Command-Line Arguments
      rcp recognizes the following command-line arguments:
           source file    Name of existing file or directory on local or
           source dir     remote machine that is to be copied to
                          destination.  Source file and directory names are
                          constructed as follows:
                               user_name@hostname:pathname/filename
                          or
                               user_name@hostname:pathname/dirname
                          Component parts of file and directory names are
                          described below.  If multiple existing files
                          and/or directory subtrees are specified
                          (source_file1, source_file2, ..., etc.), the
                          destination must be a directory.  Shell filename
                          expansion is allowed on both local and remote
                          systems.  Multiple files and directory subtrees
                          can be copied from one or more systems to a single
                          destination directory with a single command.
           dest_file      Name of destination file.  If hostname and
                          pathname are not specified, the existing file is
                          copied into a file named dest_file in the current
                          directory on the local system.  If dest_file
                          already exists and is writable, the existing file
Hewlett-Packard Company            - 1 -     HP-UX Release 9.0: August 1992
rcp(1)
                                                               
rcp(1)
                          is overwritten.  Destination filenames are
                          constructed the same way as source files except
                          that filename expansion characters cannot be used.
           dest_dir       Name of destination directory.  If hostname and
                          pathname are not specified, the existing file is
                          copied into a directory named dest_dir in the
                          current directory on the local system.  If
                          dest_dir already exists in the specified directory
                          path (or current directory if not specified), a
                          new directory named dest_dir is created underneath
                          the existing directory named dest_dir.
                          Destination directory names are constructed the
                          same way as source directory tree names except
                          that filename expansion characters cannot be used.
           file_or_dir    If a combination of files and directories are
                          specified for copying (either explicitly or by
                          filename expansion), only files are copied unless
                          the -r option is specified.  If the -r option is
                          present, all files and directory subtrees whose
                          names match the specified file_or_dir name are
                          copied.
           -p             Preserve (duplicate) modification times and modes
                          (permissions) of source files, ignoring the
                          current setting of the umask file creation mode
                          mask.  If this option is specified, rcp preserves
                          the sticky bit only if the target user is super-
                          user.
                          If the -p option is not specified, rcp preserves
                          the mode and owner of dest_file if it already
                          exists; otherwise rcp uses the mode of the source
                          file modified by the umask on the destination
                          host.  Modification and access times of the
                          destination file are set to the time when the copy
                          was made.
           -r             Recursively copy directory subtrees rooted at the
                          source directory name.  If any directory subtrees
                          are to be copied, rcp recursively copies each
                          subtree rooted at the specified source directory
                          name to directory dest_dir.  If source_dir is
                          being copied to an existing directory of the same
                          name, rcp creates a new directory source_dir
                          within dest_dir and copies the subtree rooted at
                          source_dir to dest_dir/source_dir.  If dest_dir
                          does not exist, rcp creates it and copies the
                          subtree rooted at source_dir to dest_dir.
Hewlett-Packard Company            - 2 -     HP-UX Release 9.0: August 1992
rcp(1)
                                                               
rcp(1)
    Constructing File and Directory Names
      As indicated above, file and directory names contain one, two, or four
      component parts:
           user_name      Login name to be used for accessing directories
                          and files on remote system.
           hostname       Hostname of remote system where directories and
                          files are located.
           pathname       Absolute directory pathname or directory pathname
                          relative to the login directory of user user_name.
           filename       Actual name of source or destination file.
                          Filename expansion is allowed on source file
                          names.
           dirname        Actual name of source or destination directory
                          subtree.  Filename expansion is allowed on source
                          directory names.
      Each file or directory argument is either a remote file name of the
      form hostname:path, or a local file name (with a / before any :).
      hostname can be either an official host name or an alias (see
      
hosts(4)
).  If hostname is of the form ruser@rhost, ruser is used on
      the remote host instead of the current user name.  An unspecified path
      (i.e.  hostname:) refers to the remote user's login directory.  If
      path does not begin with /, it is interpreted relative to the remote
      user's login directory on hostname.  Shell metacharacters in remote
      paths can be quoted with backslash (\), single quotes (''), or double
      quotes (""), so that they will be interpreted remotely.
      rcp does not prompt for passwords.  The current local user name or any
      user name specified via ruser must exist on rhost and allow remote
      command execution via
remsh(1)
and
rcmd(3)
.  
remshd(1M)
must be
      executable on the remote host.
      Third-party transfers in the form:
           rcp ruser1@rhost1:path1 ruser2@rhost2:path2
      are performed as:
           remsh rhost1 -l ruser1 rcp path1 ruser2@rhost2:path2
      Therefore, for a such a transfer to succeed, ruser2 on rhost2 must
      allow access by ruser1 from rhost1 (see
hosts.equiv(4)
).
WARNINGS
      rcp is confused by any output generated by commands in a .cshrc file
      on the remote host (see
csh(1)
).
Hewlett-Packard Company            - 3 -     HP-UX Release 9.0: August 1992
rcp(1)
                                                               
rcp(1)
      Copying a file to itself, for example:
           rcp path `hostname`:path
      may produce inconsistent results.  The current HP-UX version of rcp
      simply copies the file over itself.  However, some implementations of
      rcp, including some earlier HP-UX implementations, corrupt the file.
      In addition, the same file may be referred to in multiple ways, for
      example, via hard links, symbolic links, NFS, or in an HP-UX clustered
      environment.  It is not guaranteed that rcp will correctly copy a file
      over itself in all cases.
      Implementations of rcp based on the 4.2BSD version (including the
      implementations of rcp prior to HP-UX 7.0) require that remote users
      be specified as rhost.ruser.  If the first remote host specified in a
      third party transfer (rhost1 in the example below) uses this older
      syntax, the command must have the form:
           rcp ruser1@rhost1:path1 rhost2.ruser2:path2
      since the target is interpreted by rhost1.  A common problem that is
      encountered is when two remote files are to be copied to a remote
      target that specifies a remote user.  If the two remote source
      systems, rhost1 and rhost2, each expect a different form for the
      remote target, the command:
           rcp rhost1:path1 rhost2:path2 rhost3.ruser3:path3
      will certainly fail on one of the source systems.  Perform such a
      transfer using two separate commands.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/55091/showart_1776799.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP