Sturm 270 Veteran Poster

Ok so I made the following script:

#!/bin/sh

if ! ps -C screen > /dev/null
then
	exec xterm -fg green -bg black -e screen
else
	if ps -C xterm > /dev/null
	then
		exec xterm -fg green -bg black -e screen
	else
		exec xterm -fg green -bg black -e screen -r 
	fi
fi

This script is run whenever I open a terminal. The problem is that on line 11 and error occurs if there are multiple screen sessions unattached screen sessions. Is there anyway to determine the pid of a
process?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.