Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm working on a lab for a cyber-security class and need to find out when certain users are communicating with each other (through named pipes).

The users use:

python gameProgram.py

And then that process takes input and writes it to the named pipes.

I know of the /dev/random file which is modified when someone types, but that can't tell me WHO it typing, right?

I'm thinking of using something like:

grep "voluntary_switches" /proc/####/sched

I'm honestly pretty stuck. The above just returns an integer. Plus I need to get the process number somehow. I'm now struggling with coming up with a script that will let me go from (A) a list of running processes to (B) outputting a username when that user is typing. And unfortunately no sudo privileges.

I need to do something along the lines of:

echo 'ps | grep "python" |    ???    |  grep "voluntary_switches"'

Sort of ...?

Any help would be greatly appreciated!

share|improve this question

closed as not constructive by Keltari, Brad Patton, Dave, Dave M, 8088 Apr 23 '13 at 16:46

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

The goal of the exercise is to train you in a different way of thinking so an answer with a 20 line bash script to just solve your problem won't really help. To put the question in some other words

How can user Alice, using off-the-mill Unix commands only, determine whether user Bob is active/typing?

One way to solve that is to look at all the information Bob (or the processes run by Bob) are "leaking" via standard Unix functionality, in this case primarily the process table (which is accessed by ps, top and a bunch of other tools). To find out what information is available, it's best to experiment:

  • Log in once and run python gameProgram.py with a friend of yours (don't type anything let, just let it idle)
  • Log in with a second session and use ps to look at the python process. Does any information change while nobody is typing or is everything staying the same between different calls to ps?
  • Start typing/chatting with your friend
  • Use ps again to see whether anything changes in the output now (something at least will). Can you use this to your advantage?

Once you have the basics together (i.e. know which information from ps is relevant to determine user activity), combine everything together in a shell script.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.