LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-27-2011, 05:32 AM   #1
Rendman
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Rep: Reputation: 0
Question Sending commands to a screen session owned by root.


I am a linux newbie. I have a situation where I need to send a command line -X command to a screen session owned by root from a nonprivliged account. The command is executed by a shell script, which in turn is executed from a PHP script. Is there a way to make this work? I hope I gave enough information. If not please let me know.

Thanks,

Rendman
 
Old 01-27-2011, 05:39 AM   #2
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
Connecting to an existing screen session has to be defined in the .screenrc file of the user that established the session. The lines necessary are "multiuser on" and "adduser username". However, it needs to be said that this is an ugly solution. I hope you find something else that works far more cleanly and has more flexibility.
 
Old 01-27-2011, 09:47 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,272
Blog Entries: 1

Rep: Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055Reputation: 1055
One possible solution is to add your user to the sudoers file. Then:

Code:
as root:
screen -S thesession

as user:
sudo "screen -S thesession -X stuff "ls"`echo -ne '\015'`"
 
Old 01-28-2011, 01:34 AM   #4
Rendman
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by szboardstretcher View Post
One possible solution is to add your user to the sudoers file. Then:

Code:
as root:
screen -S thesession

as user:
sudo "screen -S thesession -X stuff "ls"`echo -ne '\015'`"
I had thought of doing something like that, but as this needs to run from a script on a sever, which is unattended, I am not sure how to authenticate to sudo. Do you know of way? This would be an ideal solution if there is.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending commands to a screen session tirwit Linux - Software 6 08-08-2010 09:46 PM
root-owned file is able to be deleted with my non-root account win32sux Linux - Security 3 11-18-2008 02:00 AM
How can I have a script owned as root and run as root by a user: setuid? stickey bit? abefroman Linux - Newbie 9 04-19-2008 05:15 PM
Make a file owned by root owned by a user sharpie Linux - Newbie 2 02-26-2004 01:26 AM
vfat mount - all files are 'root' owned, but even root can't -WX d33pdream Linux - General 5 02-28-2003 02:38 AM


All times are GMT -5. The time now is 10:30 AM.

Main Menu
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