Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 352
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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