I find it easier to open a new window with javascript, you can set the size, and, perhaps, pass a query holding your variable.
Call your cgi script during the onload event.
There is more than one way to do it though.
There are many js tutorials (1000's) that can help you and it would be a waste duplicating it here.
Google is your friend!
wfsp