巴什数组作为屏幕内的说法 [英] Bash array as argument inside of screen
问题描述
下面code是不工作,因为我希望它。我可能是因为我这样做都是错的,但我认为它可能是一个报价的问题。
The below code is is not working as I expect it to. I might be because I am doing this all wrong but I think it may be a quoting issue.
#!/bin/bash
IFS=$'\n'
fortune_lines=($(fortune | fold -w 30))
Screen_Session=$(mainscreen)
Screen_OneLiner=$(screen -p 0 -S ${Screen_Session} -X stuff "`printf "say ${fortune_lines[@]}\r"`")
for var in "${Screen_OneLiner[@]}"
do
echo "${var}"
done
我想我没有正确引用一些事情,因为当我尝试执行此。我得到..
I think I am not quoting something correctly because when I attempt to execute this. I get..
line 5: mainscreen: command not found
[screen is terminating
从本质上讲,我试图添加此功能(的作品)
Essentially I am attempting to add this function (that works)
IFS=$'\n'
fortune_lines=($(fortune | fold -w 30))
要这个画面单行
screen -p 0 -S ${Screen_Session} -X stuff "`printf "say ${fortune_lines[@]}\r"`"
然后把它圈阵列
for var in "${ArrayName[@]}"
do
echo "${var}"
done
所以我不知道多远我很远(在code)来我所试图做的。任何帮助将是巨大的。
So I am not sure how far I am away (in code) to what I am trying to do. Any help would be great.
推荐答案
的由于功能要求的标记为答复继续下降,我在这里复制上述溶液评论。的
Since feature requests to mark a comment as an answer remain declined, I copy the above solution here.
我设法得到这个工作...... gist.github.com/4006586 - user1787331
I managed to get this to work... gist.github.com/4006586 – user1787331
这篇关于巴什数组作为屏幕内的说法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!