簡體   English   中英

如何在Docker容器中執行Expect腳本

[英]How to execute expect script within docker container

我有一個期望腳本,希望在docker容器中運行。 我已將文件命名為exp擴展名,並將其稱為filename.exp。 我正在使用Ubuntu docker映像。 看起來容器以#!/ usr / bin / env bash而不是#!/ usr / bin / expect開頭時能夠識別文件

pipeline.yml文件

jobs:
  - name: job-pass-files
    public: true
    plan:
      - get: resource-tutorial
      - task: create-some-files
        config:
          platform: linux
          image_resource:
            type: docker-image
            source: {repository: ubuntu}

          inputs:
            - name: resource-tutorial

          run:
            path: resource-tutorial/filename.exp

文件名

#!/usr/bin/expect

eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no user@****
#use correct prompt
set prompt ":|#|\\\$"
interact -o -nobuffer -re $prompt return
send "Password\r"
interact

在大堂執行作業時出現以下錯誤

Backend error: Exit status: 500, message: {"Type":"","Message":"runc exec: exit status 1: exec failed: container_linux.go:348: starting container process caused \"no such file or directory\"\n","Handle":"","ProcessID":"","Binary":""}

有沒有一種方法可以從Docker容器執行Expect腳本。 有支持它的圖像嗎? 我是Docker的新手,因此非常感謝您的幫助

我使用Expect腳本在我的16.04 Ubuntu容器之一中安裝需要用戶提示的程序。 確保安裝期望的二進制文件,它不包含在內。 看起來是這樣的:

Dockerfile:

<snip>

#Install yocto dependencies
RUN apt-get update && apt-get -y install gawk wget git-core diffstat unzip texinfo gcc-multilib \
  build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
  xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
  xterm repo expect locales

# Install
RUN /home/docker/scripts/install.exp

<snip>

install.exp:

#!/usr/bin/expect

set timeout -1

<snip>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM