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` ]
then
mkfifo /tmp/`whoami` ;
fi
exec script -f /tmp/`whoami`
thats it, now after user login, do cat /tmp/UserLoginName in your session 😉
Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.
Posted in bash, CLI, Scripting & CLI
March 4th, 2009 at 2:59 am
nice! I’ll add this to my arsenal.
but why not just use screen(1)? This way you should be able to share the session too.
March 4th, 2009 at 3:41 am
Yes you can do it also through screen, but i found it much simpler to use fifo and script, thinking about screen will lead me to think about what is the user actions and what if s/he deatached her screen and .. so i wanted to keep it simple 😉
yes its also works through screen.