But I think you have to name the session to reattach to then, since -d -m starts a new session. But yeah, that could work. To first create a screen session than to reattach (but in a detached mode =) ) with -D -m -p $nbr where nbr should increase by one each "for-loop-round".
I will check that out, but I found another way. So if others have this problem I, changed the script, it now looks like this:
Code:
#!/bin/bash
######## BEGIN CONFIGS #####################
#what program to run
program=btdownloadcurses
#dir to put conf files in
dir=/tmp/screenscript
######## END CONFIGS #####################
# create the dir where we put our config files
if [ ! -d $dir ]; then
mkdir $dir
fi
# find a file that does not exist
# that will be our conf file
nbr=0
while [ -e $dir/$nbr ]; do
let nbr++
done
conf=$dir/$nbr
touch $conf
echo source ~/.screenrc >> $conf
win=0
for i in $@; do
echo screen $win $program $i >> $conf
let win++
done
# start screen
screen -c $conf -S screenscript