/ Published in: Bash
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
if [[ "$STY" == "" ]]; then screen -r > .screenResult if [[ $? == 1 ]]; then export whoami=`whoami` export total=`cat .screenResult | grep -i "attached" | wc -l` export s=$[`cat .screenResult | grep "${whoami}-AS" | grep -iv "attached" | wc -l`] if [[ $s == 0 ]] ; then echo 'Starting new screen session as no unattached screen exist' screen -S ${whoami}-AS else export screenSessionCount=$[$s-1] echo 'Resuming the first of ' $screenSessionCount 'screen sessions' export r=`screen -r | tail -n $s | head -n 1 | awk -F. '{printf "%d\n", $1}'` screen -r $r fi else echo 'Resumed single screen' fi else echo "You are on screen $WINDOW! " fi