LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop > Linux - Screenshots
User Name
Password
Linux - 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, 07: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, 08: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, 08:39 AM   #3
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,139

Rep: Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363
probably the script has no access to the current DISPLAY environment.
 
Old 09-19-2012, 09: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, 09:27 AM   #5
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,139

Rep: Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363
the script should be started by the user, so try setuid
 
Old 09-19-2012, 09: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, 10:01 AM   #7
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,139

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:33 AM
X11 error with Java Screenshot agent running as a service sboothman Linux - Software 0 05-08-2007 03:39 PM
Running as a service PacMansRancor Linux - Newbie 5 10-24-2005 02:17 PM
writing a script to take a screenshot minm Linux - Newbie 4 01-16-2005 08:38 AM
script to check if the service is running eyt Linux - Newbie 2 02-16-2004 08:27 AM


All times are GMT -5. The time now is 06:14 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration