The first part of your question is very vague. What do you mean by "take image from terminal'? The 2nd part largely depends on the OS you're using, so, again, clarification needed.
–
tinkFeb 20 '13 at 17:58

Sir what i want , if the unauthorized user try to login in your system..in response system has to do the things are ...1) provide 3 login attempts 2) capture login person image by webcam and 3) system should turn off
–
SachiNFeb 20 '13 at 18:35

2 Answers
2

On most (but not all) unix systems, PAM handles authentication, so you would need to plug your script into the PAM infrastructure. You'll need to read some parts of the PAM administrators' guide.

The PAM configuration is in /etc/pam.conf or /etc/pam.d/*. You'll want to run your script in the auth stack. Jump over it when authentication succeeds (something like [success 1] on the last required component) and make it a requisite entry.

You don't specify what you want to base your number of login attempts on. Per user? Per unit of time? Depending on the answer, you may need to include additional PAM configuration or do more work in your script.

Turning off the machine is rather silly. What if it was doing something useful, like a background computation or a remote user? The rate of login attempts at the console isn't worrying anyway, unless someone has brought hardware to automate them, in which case they can grab your hard disk and run.

Yep, we need the OS version (Linux? BSD?...) the distribution (Fedora, Debian, OpenSuSE?) the version of the distro... etc.

Without that information is really hard to tell...

Anyway, assuming that you are using some flavor of Linux and that the distribution has GStreamer framework installed or can be installed you could use GStreamer command line tools to do what you want. You actually don't need to be running an X (graphical) session AFAIK:

The question isn't about this part, SachiN has it already. The question is how to fit this into PAM (no, it can't be in a startup script: it needs to be triggered on a login attempt).
–
GillesFeb 21 '13 at 1:43

.My system is single desktop machine using OS Ubuntu 12.04... #!/bin/bash ts=date +%s ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 3 /home/sachin/Desktop/vid-$ts.%01d.jpg shutdown -f exit 0 This is my script its executable at terminal.it working takes image and shutdown properly, now what i want it should run on login failures after 3 attempts,supposing that no other user on system.
–
SachiNFeb 22 '13 at 5:26