0

I have created a zsh script launching many screens in detached mode with particular names and running particular processes in them in order to automate some data analysis in high energy physics. However, I get the following error occasionally:

No screen session found.

I did not recognize a particular pattern for this error to be displayed and it seems to be taking place randomly, my aim is to launch this program many times with different command-line arguments and sometimes this error pops up in the second execution and sometimes in the third. In order to be able to perform the analysis, I need to send the particular command to the screens defined inside the for loops. The code is as follows:

#! /bin/zsh
### Script for running everything in screens ###
### System argument screen name suffix ###
echo You have the following screens running:
screen -ls
#echo Press any key to proceed. NOTE THAT YOUR OTHER SCREENS WILL GET KILLED!
#read
#pkill -15 -U arisevon screen ## We make sure that no screens are running for now
bkgarr=(TopJets BosonJets DiBoson TTbar)
sigarr=(NM1 NM2 NM3 Scenario4 Scenario6)
puarr=(50PU 140PU)
lumarr=(30 300 3000)
echo Please type 1 for 50PU samples and 2 for 140PU samples
read PU
if [[ $PU -ne 1 && $PU -ne 2 ]] ; then
    echo You have to enter 1 or 2
    return 1
fi

echo Please type 1 for 300fb-1 and 2 for 3000fb-1
read lum

if [[ $lum -ne 1 && $lum -ne 2 ]] ; then
    echo You have to enter 1 or 2
    return 1
fi

if [ $PU = 1 ]; then
    let "lum = $lum + 1"
    #echo $lum
fi

ex NEWrunReader.py  <<EOEX
  :43s/Lumi.*/Lumi=$lumarr[lum]/
  :x
EOEX

echo Compiling the reader file!!!
root -l << EOF
.L readerSummerStd.C+
EOF

echo Press any key to proceed or Ctrl+C to abort!
read 

for index in $bkgarr
do
    screen -dmS "${index}_${lumarr[lum]}_${1}" 
    #screen -S $index -p 0 -X stuff "$(typeset -p bkgarr)"$'\r'
    screen -S "${index}_${lumarr[lum]}_${1}" -p 0 -X stuff "./NEWrunReader.py SummerStd $puarr[PU]_$index $1 >& "${index}_${lumarr[lum]}_${1}".txt &"$'\r'
done

for sigind in $sigarr
do
    screen -dmS "${sigind}_${lumarr[lum]}_${1}" 
    #screen -S $sigind -p 0 -X stuff "$(typeset -p bkgarr)"$'\r'
    screen -S "${sigind}_${lumarr[lum]}_${1}" -p 0 -X stuff "./NEWrunReader.py SummerStd $puarr[PU]_$sigind $1 >& "${sigind}_${lumarr[lum]}_${1}".txt &"$'\r'
done
return 0
  • only guessing but it is possible you have race condition such that you stuff command is issued before the screen session has been initialised thus not visible. I'm also unsure about your stuff command because you provide some file name aftter >&. Even if it works, I think this still could be one line instead of 2 ... – Bananguin Aug 31 '14 at 23:09
  • @Bananguin I put some sleep stament inside the for loops and now it works fine. – Vesnog Sep 1 '14 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.