0
#!/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 -e "${var}"
done

The above script only prints out line 1 one of

IFS=$'\n'
fortune_lines=($(fortune | fold -w 30))

Instead of cycling through the whole index of "fortune_lines" Not sure how to make this work. Any ideas?

FYI I am only using

echo -e

to troubleshoot this script.

Adrian Frühwirth
  • 42,970
  • 10
  • 60
  • 71
RandomNumberFun
  • 638
  • 2
  • 8
  • 25

1 Answers1

0
#!/bin/bash
#OLDIFS=$IFS
IFS=$'\r'
    fortune_lines=($(cat /etc/passwd | fold -w 30))
    #Screen_Session=$"{mainscreen}"
        Screen_Session=`screen -ls|grep "\."|grep "("|awk '{print $1}'`
    Screen_OneLiner=$(screen -p 0 -S ${Screen_Session} -X stuff "`printf "say   ${fortune_lines[@]}\r"`")
#IFS=$OLDIFS;
    for var in "${Screen_OneLiner[@]}"
      do
        echo -e "${var}"
    done

works fine for me I changed IFS to \r and it pumped out /etc/passwd where as with \n it only printed 1st line

V H
  • 8,382
  • 2
  • 28
  • 48