So this .sh is the array that works fine (I think ) for what I need it to do.
#!/bin/bash
IFS=$'\n'
fortune_lines=($(fortune | fold -w 30))
for var in "${fortune_lines[@]}"
do
echo "${var}"
done
but I want to append that array into a loop that would look like this (its not working - and I really have no idea what the next step should be to make this work ) but here is a rough idea
#!/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
Then when executed I get a black window, in the bottom bar it says
"cannot exec stuff"
Then the terminal that I am
./
the .sh from prints and drops back to the prompt
line 5: mainscreen: command not found
[screen is terminating]
Other info
I am starting my screen session (Screen version 4.00.03 (FAU) 23-Oct-06
) using
screen -S mainscreen
and the bash version I am using is
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
... if stuff exists at all. Why don't you start with simple commands and constant parameters in your Screen_OneLiner? And, again, execution logs would help us help you.