The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 05:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 03:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl Linux 5 07-30-2007 05:26 AM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr HP-UX 1 10-16-2006 01:16 PM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr Shell Programming and Scripting 0 09-19-2006 06:44 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-14-2007
Registered User
 

Join Date: Jun 2004
Location: Beijing, China
Posts: 49
rsh command

we want to execute remote script via rsh (we just only should use rsh except others),but rsh command can not set environment variable for specify user, then scripts can not be executed correctly,anyone knows how to fix this problem? thanks.
Reply With Quote
Forum Sponsor
  #2  
Old 11-14-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Put the environment variable assignment in the command to execute...

Code:
rsh remote-host "FOO=bar do-thing"
Reply With Quote
  #3  
Old 11-14-2007
Registered User
 

Join Date: Jun 2004
Location: Beijing, China
Posts: 49
Because the command required many environment variables which are defined in the specify user's profile:.bash_profile, we create a executed scripts.First in scripts, we want to execute .bash_profile to set evnironment, secondly, to run the program. The scripts looks like the following
Code:
    #!/sbin/sh
      .   .bash_profile   or . .profile           # set the environment variable
      ...
      do-something
The rsh can not run the script normally.

Last edited by Frank2004; 11-14-2007 at 11:44 PM.
Reply With Quote
  #4  
Old 11-15-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Why have you got "#!/sbin/sh" ?

What is it you are wanting? You can include environment variables in the command as I've shown. Alternatively have the variables in the user's .profile on the other machine. I notice you did not use "$HOME/.profile".
Reply With Quote
  #5  
Old 11-15-2007
Registered User
 

Join Date: Jun 2004
Location: Beijing, China
Posts: 49
"#!/sbin/sh" told the system the current shell is :/sbin/sh.

we do not want to put all environment variables in the rsh command line as you show. So we edit a shell script named shell-script on the remote host, this script include the contents I've described:
Code:
    HOME=/data/users/osa
   .  $HOME/.profile or  .  $HOME/.bash_profille
   ...
   nohup $HOME/bin/my_program
on the local host, we excute the above script on the remote-host likes this:
rsh remote-host -l remote-user shell-script.
Reply With Quote
  #6  
Old 11-15-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Why do you need to set up HOME in the script if the goal is to run the user's .profile?
Reply With Quote
  #7  
Old 11-15-2007
Registered User
 

Join Date: Jun 2004
Location: Beijing, China
Posts: 49
HOME is used in user's .profile. Here redefined this variable for confirming. there is nothing to do with this, I can comment it. What I want to do is make sure the path of .profile is correct and can be excuted .
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0