-   Linux - Member Desktop Screenshots (
-   -   How can take screenshot via a script running as a service (

ibasaran 09-19-2012 06:22 AM

How can take screenshot via a script running as a service
Hi all,

i am using ubuntu 11.04

I have a python script running as a service. I started it like "sudo service python_script start"

I want to take screenshot any login user. i tried to run "import -window root /tmp/screenshot.png" command in my python_script but no reaction. Also tries 'su active_user -c import -window root /tmp/screenshot.png nothing changed.

there is no problem when I run it like "sudo python_script" when logged in as a user but when i run it like service there is no reaction.

How can i achieve this ? There is a way ?


ibasaran 09-19-2012 07:17 AM

it can be any other script only i want to take active user screenshot.

pan64 09-19-2012 07:39 AM

probably the script has no access to the current DISPLAY environment.

ibasaran 09-19-2012 08:17 AM

thnks for replay pan64

coming a signal from outside to my script and just running below ;

cmd ='import -window root /tmp/screenshot.png'
out = commands.getstatusoutput(cmd)


cmd ='su ' + active_user + " -c 'import -window root /tmp/screenshot.png'"
out = commands.getstatusoutput(cmd)

script acting like root but the active user is not root so script cant take screenshot.

Do you know pan64 how can i access to current DISPLAY ? How can i give the this access authority to script

pan64 09-19-2012 08:27 AM

the script should be started by the user, so try setuid

ibasaran 09-19-2012 08:59 AM

if the script runs by logged user, there is no problem ok but it is not solve my problem :(

pan64 09-19-2012 09:01 AM

why not? you will start a process, change user id (with setuid) and start this process

All times are GMT -5. The time now is 11:16 AM.