Rumah  >  Soal Jawab  >  teks badan

python - 管道符和ssh传文件

看到可以用一条命令传输文件

gzip -c aa.txt | ssh root@192.168.1.1 " gunzip -c - > /home/bb.txt"

请问这条命令怎么理解?
还有,发现对文件夹进行这样的操作会失败,有什么办法传输文件夹么?
求指教

阿神阿神2740 hari yang lalu760

membalas semua(3)saya akan balas

  • 大家讲道理

    大家讲道理2017-04-18 10:21:20

    Penjelasan parameter arahan:

    gzip -h

    Usage: gzip [OPTION]... [FILE]...
    Compress or uncompress FILEs (by default, compress FILES in-place).
    
    Mandatory arguments to long options are mandatory for short options too.
    
      -c, --stdout      write on standard output, keep original files unchanged
      -d, --decompress  decompress
      -f, --force       force overwrite of output file and compress links
      -h, --help        give this help
      -l, --list        list compressed file contents
      -L, --license     display software license
      -n, --no-name     do not save or restore the original name and time stamp
      -N, --name        save or restore the original name and time stamp
      -q, --quiet       suppress all warnings
      -r, --recursive   operate recursively on directories
      -S, --suffix=SUF  use suffix SUF on compressed files
      -t, --test        test compressed file integrity
      -v, --verbose     verbose mode
      -V, --version     display version number
      -1, --fast        compress faster
      -9, --best        compress better
        --rsyncable   Make rsync-friendly archive
    
    With no FILE, or when FILE is -, read standard input.

    gunzip -h

    Usage: gzip [OPTION]... [FILE]...
    Compress or uncompress FILEs (by default, compress FILES in-place).
    
    Mandatory arguments to long options are mandatory for short options too.
    
      -c, --stdout      write on standard output, keep original files unchanged
      -d, --decompress  decompress
      -f, --force       force overwrite of output file and compress links
      -h, --help        give this help
      -l, --list        list compressed file contents
      -L, --license     display software license
      -n, --no-name     do not save or restore the original name and time stamp
      -N, --name        save or restore the original name and time stamp
      -q, --quiet       suppress all warnings
      -r, --recursive   operate recursively on directories
      -S, --suffix=SUF  use suffix SUF on compressed files
      -t, --test        test compressed file integrity
      -v, --verbose     verbose mode
      -V, --version     display version number
      -1, --fast        compress faster
      -9, --best        compress better
        --rsyncable   Make rsync-friendly archive
    
    With no FILE, or when FILE is -, read standard input.
    
    Report bugs to <bug-gzip@gnu.org>.

    Saya tidak tahu apa yang sedang berlaku. Dokumen bantuan untuk kedua-dua arahan adalah sama Dalam erti kata lain,

    tidak memampatkan fail, tetapi mengeluarkannya terus kepada output standard.

    -c

    , bukannya menerima fail termampat daripada fail, sebaliknya menerimanya daripada input standard.

    gunzip -

    : paip

    |: ubah hala
    >

    Analisis keseluruhan arahan
    gzip -c aa.txt | ssh root@192.168.1.1 "gunzip -c - > /home/bb.txt"

    • : Mampatkan fail aa.txt dan keluarkan hasil termampat kepada

      output standardgzip -c aa.txt

    • Laksanakan perintah

      pada mesin jauhssh root@192.168.1.1 "命令":

    • Arahan
    • : Nyahmampat fail Fail termampat asal dihantar masuk daripada input standard, dan hasil output terus dikeluarkan kepada output standard

      gunzip -c -.

    • : Ubah hala output standard ke fail

      > /home/bb.txt/home/bb.txt

    Operasi pada folder ini akan gagal

    gzip tidak menyokong operasi direktori

    balas
    0
  • 阿神

    阿神2017-04-18 10:21:20

    Anda boleh sama ada bertukar sepenuhnya kepada netcat untuk menghantar dan menerima.
    Atau, mampatkannya dengan tar tempatan dan nyahmampatkannya pada hujung yang bertentangan.

    balas
    0
  • PHP中文网

    PHP中文网2017-04-18 10:21:20

    Piping mengambil output arahan sebelumnya sebagai input. Anda juga boleh memampatkannya menjadi fail sementara dahulu, kemudian gunakan scp

    balas
    0
  • Batalbalas