LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-08-2009, 03:33 AM   #1
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Rep: Reputation: 34
"screen" not working properly ( .screen folder in wrong place)


I'm having a problem with screen. I have a script that I've used for years on Slackware and suddenly (with 12.2, and possibly earlier) it's stopped working as expected.

I can't say what the last version of Slackware was that worked definitively but I'm pretty sure I've used it on most versions from 9 upwards without a problem. The problem only shows itself when executed from /etc/rc.d/rc.local, which I don't always do, but there are several machines I've built which do exactly that.

The script is trivial and just creates several "screen" (screen -A -m -d -S and I've also tried -l because it looked like it might help) sessions for various programs. It works 100% of the time if I'm logged in with no problems at all. However, I sometimes put this script into /etc/rc.d/rc.local so that I have several screen's loaded at startup (before anyone logs in) with various information (this is useful, for example, with things like top, iptraf, watching logs, etc. so that I don't have to remember where they are... I can just login and look at "screen -list" to get any one of them I want and they would have been running from very early on in the boot, so even if I don't login to the machine for a month, the programs would have been collecting information for that long...). I know there are other ways of doing such things, but I quite like my way.

Anyway, I have a machine that DEFINITELY uses an identical script installed in an identical way on an earlier version of Slackware that, when called from rc.local works just fine. But on 12.2, I have a machine that creates the screen sessions just fine but for some reason places the .screen folder in / rather than the normal $HOME. It seems that $HOME is set to / rather than /root in the case of rc.local startups. Although I can understand some rationale for this, has nobody else spotted the change or is it just me?

It's obviously some sort of environment issue but could someone enlighten me to when the change was made, what change was made and why it was made? And does anyone know how it might be possible to workaround the problem - as it is, the programs just die or they end up with a pipe in /.screen/ instead of /root/.screen/ (so the root user doesn't see them under screen -list). But if you login and then issue the screen commands, everything works fine.
 
Old 01-08-2009, 04:40 AM   #2
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
1. su - USER_NAME -c YOUR_COMMAND
This will setup your environment. I always do so.

2. If you didn't follow 1., you could still use
HOME=/ screen -r
to re-attach your session.
 
Old 01-08-2009, 05:16 AM   #3
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by guanx View Post
1. su - USER_NAME -c YOUR_COMMAND
This will setup your environment. I always do so.
Quote:
Originally Posted by guanx View Post
2. If you didn't follow 1., you could still use
HOME=/ screen -r
to re-attach your session.
I know this, but that's no use to me if I want the programs to run in a screen from the very start of the computer booting up. I'd use Virtual Consoles but they really only work when you are local.

Just as an example of the type of usage:

1) Computer runs, say, iptraf, kismet or other console-based program, at startup without any user having to login (blackbox systems).
2) Occasionally I need to login remotely to the device, and see the output of iptraf in a nice graphical way (yes, I can grep logs etc. but that's not what I want to do for a quick check) but I need to see an iptraf that was running from the second the computer was up on the network.

Running it in a screen works perfectly because you can login remotely, resume the screen and see/interact with the program which was running from the first boot and will continue running until you switch the machine off. You can also show that same screen on a VC at the same time. However, screen doesn't want to work (lately, I've done this before, though) from an init script because of this environment issue. The environment gets set up the second you login or su to root, but that's *too late* for the program.

Some of the programs I want to use will even refuse to start if they don't have $HOME set up to a nice writable folder (i.e. something other than /) when you run then, so you end up with, out of seven programs I want to run in this fashion, three running on screens that you have to faff about to connect to and four processes which just die instantly.

I don't really want to play with $HOME from within the rc.local script but if I need to, I will. I just wondered what change was made to do this and why it was made... I've definitely done this before on slackware without problems (not that long ago, either).
 
Old 01-08-2009, 01:38 PM   #4
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by ledow View Post
I know this, but that's no use to me if I want the programs to run in a screen from the very start of the computer booting up.
...
If you don't take others' advices, why do you ask for them at all?

It doesn't work simply because you don't try it. I always use "su" for my screen sessions in "rc.local", not only for having a proper "$HOME" but also for dropping some privileges. Here is an example:
Code:
su - USER_NAME -c 'screen -d -m YOUR_COMMAND'
If you really don't want to change "$HOME" from "/", you can set "$SCREENDIR" to a proper directory. See the man pages in screen(1).

btw, I've digged out my Slackware 10.2 disc and made sure that "$HOME" is "/" in rc.local.

Last edited by guanx; 01-08-2009 at 02:06 PM.
 
Old 01-11-2009, 02:54 PM   #5
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
If you run

su - root -c 'screen command'

Wouldn't that use /root/ as HOME?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Lock Screen" is not working on Fedora Core 5 jialin Fedora 2 04-05-2008 08:37 AM
Screen goes to "grub>" black screen after trying to merge 2 drives Planet-Zhar Linux - General 4 06-20-2007 04:46 AM
"Lock Screen" in Gnome not working SlowCoder Linux - Newbie 0 05-27-2006 07:12 PM
MDK 9.2: X freezes with a black screen or blue screen with "X cursor" Apoc Linux - Newbie 10 03-30-2004 03:38 PM
MDK 9.2: X freezes on a black screen or blue screen with "X cursor" Apoc Linux - Software 1 12-29-2003 03:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:57 PM.

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