• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

startx as a user

Hello,

I'm running really simple installation of debian. There are no KDM or GDM.  xserver is running properly. What I would like to do is to start X as a user foobar and then once X running automatically start perl script myapplication.pl as a user root. What I have tried is:

chmod +s myapplication.pl -  this would not work

any hints?

thank you
0
Luxana
Asked:
Luxana
  • 3
  • 2
2 Solutions
 
Gabriel OrozcoSolution ArchitectCommented:
use sudo to run scripts as root

do shell script "echo password | sudo -S command"

or

do shell script "sudo -S command <password.txt"
0
 
LuxanaAuthor Commented:
where would you put perl script?
0
 
Gabriel OrozcoSolution ArchitectCommented:
replace "command" with your perl script name

just be sure your perl script has the shebang line referencing perl executable

#!/usr/bin/perl  (if perl is in there)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
WizRd-LinuxCommented:
where would you put perl script?
---
Put it somewhere like /usr/bin but make sure that only root has write access to the file, otherwise users could change it for other malicious purposes if you allow it to execute without a password.
0
 
LuxanaAuthor Commented:
Hi WizRd-Linux,

but if I put it in /usr/bin it does not get executed after user starts startx

0
 
Gabriel OrozcoSolution ArchitectCommented:
undestood.

The most basic way to start X is with xinit. This will put you at a blank desktop, by default, and with no window manager loaded. If no client program is specified on the command line, xinit will look for the .xinitrc file to run as a shell script, to start up client programs.

you can put something you want to be started on the user's  ~/.xinitrc

-or- you may create a batch file that starts x and then starts your script.

if your script is graphic, maybe you will need to set your DISPLAY environment variable to be

DISPLAY=0.0
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now