diff --git a/content/post/transfer-file-content-using-xclip-in-terminal.md b/content/post/transfer-file-content-using-xclip-in-terminal.md new file mode 100644 index 00000000..1f6fb1e0 --- /dev/null +++ b/content/post/transfer-file-content-using-xclip-in-terminal.md @@ -0,0 +1,89 @@ +--- +title: "Transfer File Content Using Xclip in Terminal" +date: 2019-05-17T12:18:54+08:00 +draft: false + +noSummary: false +featuredImage: "https://h.cowbay.org/images/post-default-11.jpg" +categories: ['linux'] +tags: ['linux'] +author: "Eric Chang" +--- + +工作上常會需要用ssh登入遠端主機檢查LOG,有必要的時候,還要把log複製回本機來處理。 + +以前都是傻傻的用 scp 傳檔案 + +之前就記得有這個xclip/xsel 可以用,但是一直沒有弄清楚怎麼執行 + +早上研究了一下,順便做個筆記。 + + + +### 1. ssh 要加上 -X ### +不然會出現 + +``` +Error: Can't open display: (null) +``` + +這種錯誤訊息 + +``` +-X Enables X11 forwarding. This can also be specified on a per-host basis in a configuration file. + + X11 forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the user's X + authorization database) can access the local X11 display through the forwarded connection. An attacker may then be able to perform activi‐ + ties such as keystroke monitoring. + + For this reason, X11 forwarding is subjected to X11 SECURITY extension restrictions by default. Please refer to the ssh -Y option and the + ForwardX11Trusted directive in ssh_config(5) for more information. +``` + +### 2. remote 主機要安裝 xclip / xsel ### +``` +2019-05-17 10:12:20 [minion@hqs019 ~]$ sudo apt install xsel +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following NEW packages will be installed: + xsel +0 upgraded, 1 newly installed, 0 to remove and 73 not upgraded. +Need to get 19.0 kB of archives. +After this operation, 47.1 kB of additional disk space will be used. +Get:1 http://ftp.tw.debian.org/ubuntu bionic/universe amd64 xsel amd64 1.2.0-4 [19.0 kB] +Fetched 19.0 kB in 0s (80.3 kB/s) +Selecting previously unselected package xsel. +(Reading database ... 161032 files and directories currently installed.) +Preparing to unpack .../xsel_1.2.0-4_amd64.deb ... +Unpacking xsel (1.2.0-4) ... +Processing triggers for man-db (2.8.3-2ubuntu0.1) ... +Setting up xsel (1.2.0-4) ... + +2019-05-17 10:13:32 [minion@hqs019 ~]$ sudo apt install xclip +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following NEW packages will be installed: + xclip +0 upgraded, 1 newly installed, 0 to remove and 73 not upgraded. +Need to get 17.5 kB of archives. +After this operation, 52.2 kB of additional disk space will be used. +Get:1 http://ftp.tw.debian.org/ubuntu bionic/main amd64 xclip amd64 0.12+svn84-4build1 [17.5 kB] +Fetched 17.5 kB in 1s (16.2 kB/s) +Selecting previously unselected package xclip. +(Reading database ... 161038 files and directories currently installed.) +Preparing to unpack .../xclip_0.12+svn84-4build1_amd64.deb ... +Unpacking xclip (0.12+svn84-4build1) ... +Setting up xclip (0.12+svn84-4build1) ... +Processing triggers for man-db (2.8.3-2ubuntu0.1) ... +``` + +### 3.執行方式 + +執行以下指令,就可以把遠端的檔案內容傳送到「系統剪貼簿」,在本機就可以直接貼上了 + + +``` +cat copy_neonexus.csv |xclip -selection clipboard +``` diff --git a/public/404.html b/public/404.html index df2c25c1..20276832 100644 --- a/public/404.html +++ b/public/404.html @@ -115,6 +115,10 @@ @@ -156,6 +156,10 @@ 筆記 (18) +
  • + Linux (1) +
  • +
  • Ps (1)
  • diff --git a/public/author/eric-chang/index.html b/public/author/eric-chang/index.html index 9e60354b..4eacef8d 100644 --- a/public/author/eric-chang/index.html +++ b/public/author/eric-chang/index.html @@ -90,6 +90,85 @@ +
    + + + + + +
    + + + + +
    +

    Transfer File Content Using Xclip in Terminal

    +
    + + + 2019-05-17 + + + + + + + + + linux + + + + + + Eric Chang + +
    + + +

    工作上常會需要用ssh登入遠端主機檢查LOG,有必要的時候,還要把log複製回本機來處理。

    + +

    以前都是傻傻的用 scp 傳檔案

    + +

    之前就記得有這個xclip/xsel 可以用,但是一直沒有弄清楚怎麼執行

    + +

    早上研究了一下,順便做個筆記。

    + +

    + + + + + +
    + + + + +
    + + +
    +
    @@ -773,87 +852,6 @@ -
    - - - - - - -
    - - - - - -
    - - - - -
    -

    [碎念] mdadm 超級慢的rebuild 速度 Incredibly Slow mdadm Rebuild

    -
    - - - 2018-12-12 - - - - - - - - - 碎念 - - - - - - Eric Chang - -
    - - -

    最近在做一台老機器的P2V

    - -

    偏偏user說不能關機,所以我用dd + ssh 做線上移轉

    - -

    這部份有空再來寫

    - -

    只是因為原來的設定有用mdadm 做raid1

    - -

    這部份導致移轉過去proxmox 後,會出現raid degrade 導致無法正常開機

    - -

    - - - - - -
    - - -
    @@ -884,6 +882,10 @@
    @@ -925,6 +923,10 @@ 筆記 (18) +
  • + Linux (1) +
  • +
  • Ps (1)
  • diff --git a/public/author/eric-chang/index.xml b/public/author/eric-chang/index.xml index bb6fe3d3..49b412aa 100644 --- a/public/author/eric-chang/index.xml +++ b/public/author/eric-chang/index.xml @@ -5,11 +5,28 @@ https://h.cowbay.org/author/eric-chang/ Recent content in Eric Chang on MCの飄狂山莊㊣ Hugo -- gohugo.io - Tue, 23 Apr 2019 15:28:56 +0800 + Fri, 17 May 2019 12:18:54 +0800 + + Transfer File Content Using Xclip in Terminal + https://h.cowbay.org/post/transfer-file-content-using-xclip-in-terminal/ + Fri, 17 May 2019 12:18:54 +0800 + + https://h.cowbay.org/post/transfer-file-content-using-xclip-in-terminal/ + <p>工作上常會需要用ssh登入遠端主機檢查LOG,有必要的時候,還要把log複製回本機來處理。</p> + +<p>以前都是傻傻的用 scp 傳檔案</p> + +<p>之前就記得有這個xclip/xsel 可以用,但是一直沒有弄清楚怎麼執行</p> + +<p>早上研究了一下,順便做個筆記。</p> + +<p></p> + + [筆記] inxi 蒐集詳盡的硬體資訊 / inxi Collect Detail Hardware Info https://h.cowbay.org/post/inx-collect-detail-hardware-info/ diff --git a/public/author/eric-chang/page/2/index.html b/public/author/eric-chang/page/2/index.html index 7cecf213..4ab79229 100644 --- a/public/author/eric-chang/page/2/index.html +++ b/public/author/eric-chang/page/2/index.html @@ -90,6 +90,87 @@ +
    + + + + + +
    + + + + +
    +

    [碎念] mdadm 超級慢的rebuild 速度 Incredibly Slow mdadm Rebuild

    +
    + + + 2018-12-12 + + + + + + + + + 碎念 + + + + + + Eric Chang + +
    + + +

    最近在做一台老機器的P2V

    + +

    偏偏user說不能關機,所以我用dd + ssh 做線上移轉

    + +

    這部份有空再來寫

    + +

    只是因為原來的設定有用mdadm 做raid1

    + +

    這部份導致移轉過去proxmox 後,會出現raid degrade 導致無法正常開機

    + +

    + + + + + +
    + + + + +
    + + +
    +
    @@ -870,97 +951,6 @@ -
    - - - - - - -
    - - - - - -
    - - - - -
    -

    Bookstack Docker

    -
    - - - 2018-11-06 - - - - - - - - - 筆記 - - - - - - Eric Chang - -
    - - -

    Bookstack 是一套非常好用的線上”筆記”系統

    - -

    他用圖書館/書本的概念,讓使用者可以建立自己的”圖書館”

    - -

    同時在圖書館內建立不同的”書籍”

    - -

    而且支援 Markdown 語法

    - -

    其他的方式像是在nextcloud上編輯 md檔案(字體太小)

    - -

    或者是boostnote(只能在本機)

    - -

    都或多或少有點小缺點

    - -

    Bookstack則是沒有這些問題,不過就是系統「大」了點…

    - -

    不過還好有人做成docker的方式來啟動,大大的降低了建置的難度(其實也沒有很難啦,只是要裝個PHP、弄個DB而已)

    - -

    - - - - - -
    - - -
    @@ -993,6 +983,10 @@
    @@ -1034,6 +1024,10 @@ 筆記 (18) +
  • + Linux (1) +
  • +
  • Ps (1)
  • diff --git a/public/author/eric-chang/page/3/index.html b/public/author/eric-chang/page/3/index.html index 9f7bca76..1e1d13c2 100644 --- a/public/author/eric-chang/page/3/index.html +++ b/public/author/eric-chang/page/3/index.html @@ -90,6 +90,97 @@ +
    + + + + + +
    + + + + +
    +

    Bookstack Docker

    +
    + + + 2018-11-06 + + + + + + + + + 筆記 + + + + + + Eric Chang + +
    + + +

    Bookstack 是一套非常好用的線上”筆記”系統

    + +

    他用圖書館/書本的概念,讓使用者可以建立自己的”圖書館”

    + +

    同時在圖書館內建立不同的”書籍”

    + +

    而且支援 Markdown 語法

    + +

    其他的方式像是在nextcloud上編輯 md檔案(字體太小)

    + +

    或者是boostnote(只能在本機)

    + +

    都或多或少有點小缺點

    + +

    Bookstack則是沒有這些問題,不過就是系統「大」了點…

    + +

    不過還好有人做成docker的方式來啟動,大大的降低了建置的難度(其實也沒有很難啦,只是要裝個PHP、弄個DB而已)

    + +

    + + + + + +
    + + + + +
    + + +
    +
    @@ -273,6 +364,10 @@
    @@ -314,6 +405,10 @@ 筆記 (18) +
  • + Linux (1) +
  • +
  • Ps (1)
  • diff --git a/public/author/index.html b/public/author/index.html index c4c16993..e30e0d93 100644 --- a/public/author/index.html +++ b/public/author/index.html @@ -101,7 +101,7 @@
    @@ -120,6 +120,10 @@ @@ -161,6 +161,10 @@ 筆記 (18) +
  • + Linux (1) +
  • +
  • Ps (1)
  • diff --git a/public/author/index.xml b/public/author/index.xml index 0553eb33..45d709b9 100644 --- a/public/author/index.xml +++ b/public/author/index.xml @@ -12,7 +12,7 @@ Eric Chang https://h.cowbay.org/author/eric-chang/ - Tue, 23 Apr 2019 15:28:56 +0800 + Fri, 17 May 2019 12:18:54 +0800 https://h.cowbay.org/author/eric-chang/ diff --git a/public/categories/index.html b/public/categories/index.html index 244a061e..00e7df9a 100644 --- a/public/categories/index.html +++ b/public/categories/index.html @@ -101,6 +101,8 @@