LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 11-20-2009, 03:56 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 12.2 (2.6.27.59), 13.1 (2.6.33.15)
Posts: 2,550

Rep: Reputation: 255Reputation: 255Reputation: 255
SSH and at Command Behavior


I noticed something peculiar about the at command and SSH.

When I ssh into a box as username1, then su to username2, then pipe a command to the at command, the resulting at script (/var/spool/atjobs) contains the environment variables of username1 rather than username2.

If I su to username2 and then ssh into the other box, the resulting at script grabs the environment variables of username2.

Both username1 and username2 are mortal user accounts.

Anybody care to explain (not speculate ) why the first scenario happens?

Last edited by Woodsman; 11-20-2009 at 04:46 PM.
 
Old 11-20-2009, 04:07 PM   #2
TBC Cosmo
Member
 
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 352

Rep: Reputation: 43
So as not to speculate, please provide the exact command you are using to su to the other account.
 
Old 11-20-2009, 04:55 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 12.2 (2.6.27.59), 13.1 (2.6.33.15)
Posts: 2,550

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
So as not to speculate, please provide the exact command you are using to su to the other account.
1. login as user1 at box1
2. open a terminal window; in my case - Konsole
3. ssh box2
4. su user2
5. echo '/usr/local/bin/shellscript' | at hh:mm mm/dd/yyyy

As root, open the newly created at job script in /var/spool/atjobs. Notice the environment variables are from user1's environment, and not user2's environment.

1. login as user1 at box1
2. open a terminal window; in my case - Konsole
3. su user2
4. ssh box2
5. echo '/usr/local/bin/shellscript' | at hh:mm mm/dd/yyyy

As root, open the newly created at job script in /var/spool/atjobs. Notice the environment variables are from user2's environment --- as expected.
 
Old 11-20-2009, 05:08 PM   #4
tux_dude
Member
 
Registered: Dec 2008
Distribution: Slackware 12.2, Slackware Current 32/64
Posts: 137

Rep: Reputation: 26
You need to do su - user2. The - loads user2 environment variable. Without the - all user1 environment variables are retained.
 
1 members found this post helpful.
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Behavior of Command Line Expansion in touch command ahmedb72 Linux - Newbie 10 07-01-2009 03:51 AM
Basic menu.sh fails: strange behavior on echo command. budhax Programming 3 09-05-2008 07:04 PM
Strange Behavior - chown command Ingla Linux - General 8 01-28-2007 05:46 AM
ls command behavior day4night Linux - Newbie 7 01-25-2004 01:57 AM
Unexpected Behavior (passwd command) Penguin666 Linux - General 3 11-20-2003 12:34 AM


All times are GMT -5. The time now is 07:27 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
Open Source Consulting | Domain Registration