Automatically detach screen after given amount of time ? / Authpf in background ?

Frank Staals frankstaals at
Thu Feb 1 09:46:21 UTC 2007

A couple days ago I set up authpf on my FreeBSD gateway for 
authentication of my wifi network. Everything works great, the only 
thing that is/was bothering me was that I had to keep open a terminal on 
my laptop for the ssh session. I quickly thought of using screen to fix 
that  problem. The thing is I want to see the confirmation authpf gives 
when starting the ssh transfer ( The 'welcome <username> you are 
authenticated from <ip>' message ). After that it should just send the 
ssh session to the background. So I came up with this script :

frank at Riza$ cat /home/scripts/root/seescreen

#### script to log in to connect to screen for only a set amount of time

## Settings to use:
rtime="3" ## time to wait before calling screen's reatach
dtime="4" ## time to wait before calling screen's detach

# if called with '-reatach'
if [ "$1" = "-reatach" ] ; then
        sleep $rtime

        seescreen -detach &

        screen -r
# if called with '-detach'

if [ "$1" = "-detach" ] ; then
        sleep $dtime

        screen -d

now I could start my authentication session with 'screen -wipe; sudo 
wlan ; seescreen -reatach ; screen -d -m ssh -l wifi wlanserver'. ( 
where wlan is an other script to set up my wlan connection '. I made an 
alias in my bashrc file to prevent typing all this. The weird thing is 
that the first times I ran my script during testruns I could set the 
rtime to 1 but then it seemed that wasn't enouth time so I had to make 2 
of it and everything worked again. But then it didn't work with 2 either 
and I had to set it to 3 and now even 3 doesn't seem enough to reconnect 
to my screen session. It shouldn't take that long to start the 'screen 
-d -m <command>' does it ?

So my question was: Am I missing something resulting in the need of a 
longer rtime ? If there is nothing wrong with it what would be a good 
value ? Or is there some other way I could run my ssh session in the 
background ?


-Frank Staals

More information about the freebsd-questions mailing list