Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell Kubernetes从脚本块执行pod中的cat_Shell_Kubernetes_Cat - Fatal编程技术网

Shell Kubernetes从脚本块执行pod中的cat

Shell Kubernetes从脚本块执行pod中的cat,shell,kubernetes,cat,Shell,Kubernetes,Cat,以下脚本有效: #!/bin/bash kubectl exec -ti mypod -- bash -c "cat somefile" 但是 没有 chmod +x myscript.sh ./myscript.sh 提示永远不会返回 第二个脚本有什么问题? 提前感谢,, Abdelghani您缺少引号command=“cat somefile”将在变量中存储字符串cat somefile 脚本应如下所示: #!/bin/bash command="cat s

以下脚本有效:

#!/bin/bash
kubectl exec -ti mypod -- bash -c "cat somefile"
但是

没有

chmod +x myscript.sh
./myscript.sh
提示永远不会返回

第二个脚本有什么问题? 提前感谢,,
Abdelghani

您缺少引号
command=“cat somefile”
将在变量中存储字符串cat somefile

脚本应如下所示:

#!/bin/bash
command="cat somefile"
kubectl exec -ti mypod -- bash -c "$command"

作品Thkx近地天体
#!/bin/bash
command="cat somefile"
kubectl exec -ti mypod -- bash -c "$command"