Linux expect 的安裝

來源:互聯網
上載者:User

Linux expect 的安裝

expect是建立在tcl基礎上的一個工具,它還提供了一些Tcl所沒有的命令,它可以用來做一些linux下無法做到互動的一些命令操作,在遠端管理方面發揮很大的作用。

因為expect是基於tcl的,所以需要你的系統中安裝有tcl

如何檢查?

[root@dev ~]# whereis tcltcl: /usr/lib/tcl8.4 /usr/share/tcl8.4

如果看不到結果,請先安裝tcl

> 安裝tcl

下載tcl安裝包,然後解壓tcl安裝包(centos系統下可以直接使用yum install tcl; ubuntu系統下可以直接使用apt-get install tcl命令來快速安裝)

首頁: http://www.tcl.tk
: http://www.tcl.tk/software/tcltk/downloadnow84.tml

1.下載源碼包

[root@dev ~]# wget http://nchc.dl.sourceforge.net/sourceforge/tcl/tcl8.4.11-src.tar.gz

2.解壓縮源碼包

[root@dev ~]# tar xfvz tcl8.4.11-src.tar.gz

3.安裝配置

[root@dev ~]# cd tcl8.4.11/unix[root@dev ~]# ./configure --prefix=/usr/tcl --enable-shared[root@dev ~]# make[root@dev ~]# make install

安裝完畢以後,進入tcl原始碼的根目錄,把子目錄unix下面的tclUnixPort.h copy到子目錄generic中。

暫時不要刪除tcl原始碼,因為expect的安裝過程還需要用。

> 安裝expect

首頁: http://expect.nist.gov/

1.下載源碼包

[root@dev ~]# wget http://sourceforge.net/projects/expect/files/Expect/5.45/expect5.45.tar.gz/download

2.解壓縮源碼包

[root@dev ~]# tar xzvf expect5.45.tar.gz

3.安裝配置

[root@dev ~]# cd expect5.45[root@dev ~]# ./configure --prefix=/usr/expect --with-tcl=/usr/local/tcl/lib --with-tclinclude=/opt/tcl8.4.11/generic/ --enable-shared[root@dev ~]# make[root@dev ~]# make install

注意:指定的 /opt/tcl8.4.11/generic/ 為我們上面解壓的tcl目錄

> 建立串連符號

[root@dev ~]# ln -s /usr/local/expect/bin/expect /usr/bin/expect

> 查看串連符號

[root@dev ~]# ls -l /usr/bin/expectlrwxrwxrwx. 1 root root 28 9月   8 11:21 /usr/bin/expect -> /usr/local/expect/bin/expect

這個符號連結將在編寫expect指令檔時用到,例如在expect檔案頭部會指定用於執行該指令碼的shell

#!/usr/bin/expect

> 測試

[root@dev ~]# expectexpect1.1> exit[root@dev ~]#  

這樣就可以開始運行expect指令碼了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.