March 4, 2009
Two days ago i did a nice interview, it was interactive exam, someone ask you through the phone to troubleshoot/do many things and in the same time he see what you do and what is the output of your commands, in my company, when i was interviewing people, all what i do is oral questions.. its oral conversation, but after making that interview i decided to prepare a examination machine to use it for future interviews i do in the company i work in.
the trick was using SCRIPT(1) and named pipe (fifo), simply like this:
in the first session do this command:
$ mkfifo foo; script -f foo
in another session do cat for ‘foo’
$ cat foo
and now you will see everything done in the first session, yup so nice.
to use it when the user login (for ex/ through ssh), you can put it on .bashrc file for that user, for example put those at the end of .bashrc file:
if [ ! -p /tmp/`whoami` ]
mkfifo /tmp/`whoami` ;
exec script -f /tmp/`whoami`
thats it, now after user login, do cat /tmp/UserLoginName in your session