# 在k8s的yaml文件中声明启动命令，运行无效

**URL:** <https://discuss.kubernetes.io/t/k8s-yaml/23794>\
**Category:** General Discussions\
**Created:** [April 11, 2023, 9:22am UTC](https://discuss.kubernetes.io/t/k8s-yaml/23794 "2023-04-11T09:22:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaokai](https://avatars.discourse-cdn.com/v4/letter/x/ea666f/32.png) [@xiaokai](https://discuss.kubernetes.io/u/xiaokai)\
**Post date:** [April 11, 2023, 9:22am UTC](https://discuss.kubernetes.io/t/k8s-yaml/23794/1 "2023-04-11T09:22:32Z")

</div>

Asking for help? Comment out what you need so we can get more information to help you!

### Cluster information:

Kubernetes version:v1.19.8  
Cloud being used: (put bare-metal if not on a public cloud)  
Installation method:  
Host OS: ubuntu  
CNI and version:  
CRI and version:

是这样的我在k8s的yaml文件中配置了启动容器的执行命令  
command:  
- /bin/bash  
- ‘-c’  
- cd /root/ && sh /root/expect-pod.sh  
这个脚本的内容我附件在文档中  
现存的问题：目前的问题是我启动容器运行脚本，按照脚本里面的内容回生成一个文件到root目录，然后我用awk、head…来提取这个文件中我所需的内容。但是现在我做成启动命令去运行的时候直接报错，因为我提取不到这个文件，在yaml文件中是需要指定目录去执行嘛？

 ![20230411-172100](https://us1.discourse-cdn.com/flex016/uploads/kubernetes/original/2X/6/6a345639d33d4b922dcdde37d88e3c41d74b433c.jpeg)
