Search code examples
linuxbashraspberry-pi2gnu-screenautostart

Screen message "Must be connected to a terminal" when using option -D -R SessionName


I have script in bash which check for mp4 file and if it find more than one it start playing them one by one.

Script working from command line when i log in by ssh.

But when i reboot rpi, it will not start with autostart in rc.local saying

"Must be connected to a terminal"

This is part of the script

    if [ "$count_dir_video" -gt "1"  ] ;then
 53 
 54                 # make background black to hide wallpaper between videos
 55                 DISPLAY=:0 screen -dmS "black_background" feh -FxYqZ /opt/scripts/black_background.jpg
 56                 echo "przed sleep"
 57                 #screen -dmS "$1" sleep 5
 58                 echo "po sleep"
 59 
 60                         while :
 61                         do
 62                                 for entry in $root_dir_video
 63                                 do
 64 
 65                                 # multiple files
 66                                 echo "przed omx"
 67                                 screen -D -R "$1" omxplayer -o hdmi -p -b --no-osd --vol 100 "$entry" >> /var/log/sds.log
 68                                 echo "po omx"
 69                                 done
 70                         done
 71                 else
 72 
 73                         # single file
 74 
 75                         screen -dmS "$1" omxplayer -o hdmi -p -b --loop --no-osd --vol 100 "$root_dir_video"
 76                 fi

The problem is in line 67 and i cannot make it work.

I tried other parameter screen combination but always the same.

The idea is that it will start every entry in once named screen session.


Solution

  • man screen

       -D -R   Attach here and now. In detail this means: If a session is run‐
               ning, then reattach. If necessary detach  and  logout  remotely
               first.   If  it  was not running create it and notify the user.
               This is the author's favorite.
    

    Use lowercase -d with -m.