LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop > Linux - Member Desktop Screenshots
User Name
Password
Linux - Member Desktop Screenshots This forum is for the discussion and display of Linux Desktop screenshots. Please remember that many members browse LQ from work, so NSFW screenshots are not appropriate.

Notices


Reply
  Search this Thread
Old 09-19-2012, 06:22 AM   #1
ibasaran
LQ Newbie
 
Registered: Sep 2012
Posts: 8

Rep: Reputation: Disabled
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 ?

Thnks
 
Old 09-19-2012, 07:17 AM   #2
ibasaran
LQ Newbie
 
Registered: Sep 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
it can be any other script only i want to take active user screenshot.
 
Old 09-19-2012, 07:39 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,978

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
probably the script has no access to the current DISPLAY environment.
 
Old 09-19-2012, 08:17 AM   #4
ibasaran
LQ Newbie
 
Registered: Sep 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
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)
logging.debug(out)

or

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

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
 
Old 09-19-2012, 08:27 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,978

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
the script should be started by the user, so try setuid
 
Old 09-19-2012, 08:59 AM   #6
ibasaran
LQ Newbie
 
Registered: Sep 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
if the script runs by logged user, there is no problem ok but it is not solve my problem
 
Old 09-19-2012, 09:01 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,978

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux cluster service- trouble running script LostPrincess Linux - Newbie 2 01-17-2012 09:33 AM
X11 error with Java Screenshot agent running as a service sboothman Linux - Software 0 05-08-2007 02:39 PM
Running as a service PacMansRancor Linux - Newbie 5 10-24-2005 01:17 PM
writing a script to take a screenshot minm Linux - Newbie 4 01-16-2005 07:38 AM
script to check if the service is running eyt Linux - Newbie 2 02-16-2004 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop > Linux - Member Desktop Screenshots

All times are GMT -5. The time now is 03:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration