rsh and ksh question

rsh and ksh question

Post by Shivkumar Shankara » Wed, 26 Apr 2000 04:00:00



I do all my work in ksh. When a script invokes a remote shell using rsh
where does it get its environment from ? For e.g., if I do

$ rsh <remote host> env

why does it grab some minimal default env file (or something) instead of
sourcing my .profile or .kshrc. How do I get around this ? I want to run
a script which forks another shell but goes to that machine and uses my
own .profile or .kshrc on that machine.

I don't really want to do something like:

$ rsh <remote host> -l <user> -e . .kshrc

You see, C shell sources your .cshrc every time it forks a shell but for
some reason ksh doesn't. Do you know a work around ?

I DO NOT want to modify my script to read some environment file
somewhere.

thanks,
shivi shankaran.

 
 
 

rsh and ksh question

Post by Zoran Cutur » Thu, 27 Apr 2000 04:00:00



> I do all my work in ksh. When a script invokes a remote shell using rsh
> where does it get its environment from ? For e.g., if I do

> $ rsh <remote host> env

> why does it grab some minimal default env file (or something) instead of
> sourcing my .profile or .kshrc. How do I get around this ? I want to run
> a script which forks another shell but goes to that machine and uses my
> own .profile or .kshrc on that machine.

> I don't really want to do something like:

> $ rsh <remote host> -l <user> -e . .kshrc

which at all would not work since . is not a process.
and -e only sets the escape character for rlogin.

You should read the man page of rsh/rlogin/rshd/rlogind

since normally rlogin invokes login(1) to login the user
after standard i/o has been setup to point to some pty
you should get the shell that is entered in /etc/passwd
on the remote for your username.

Hope this helps
        Z

- Show quoted text -

Quote:> You see, C shell sources your .cshrc every time it forks a shell but for
> some reason ksh doesn't. Do you know a work around ?

> I DO NOT want to modify my script to read some environment file
> somewhere.

> thanks,
> shivi shankaran.


 
 
 

rsh and ksh question

Post by Dan Merc » Thu, 27 Apr 2000 04:00:00




> I do all my work in ksh. When a script invokes a remote shell using rsh
> where does it get its environment from ? For e.g., if I do

> $ rsh <remote host> env

> why does it grab some minimal default env file (or something) instead of
> sourcing my .profile or .kshrc. How do I get around this ? I want to run
> a script which forks another shell but goes to that machine and uses my
> own .profile or .kshrc on that machine.

> I don't really want to do something like:

> $ rsh <remote host> -l <user> -e . .kshrc

> You see, C shell sources your .cshrc every time it forks a shell but for
> some reason ksh doesn't. Do you know a work around ?

> I DO NOT want to modify my script to read some environment file
> somewhere.

> thanks,
> shivi shankaran.

If this is for a script,  run ksh as a coprocess.  For an example,
here's how I start hbiff:

   remsh $MAILHOST /usr/bin/ksh 2>&1 |&
   print -p "print ok"
   read -p
   [[ $REPLY != ok ]] && {
      print -u2 "$REPLY"
      exit 1
      }
   print -p "export PATH=$PATH"           # use current PATH on remote host
   print -p "export DISPLAY=$DISPLAY"
   print -p "hbiff -geometry +625+400 </dev/null >/dev/null 2>&1 &"
   print -p exit

--
Dan Mercer

Opinions expressed herein are my own and may not represent those of my employer.

 
 
 

rsh and ksh question

Post by Happl Oberli » Thu, 27 Apr 2000 04:00:00




>I do all my work in ksh. When a script invokes a remote shell using rsh
>where does it get its environment from ? For e.g., if I do
>$ rsh <remote host> env

I think, this environment comes from /etc/environment and/or
/etc/profile.

Quote:>You see, C shell sources your .cshrc every time it forks a shell but for
>some reason ksh doesn't. Do you know a work around ?

Yes: rsh <remote host> -l <user> ". ./.kshrc ; <some commands>"
or:  rsh <remote host> -l <user> ". ./.profile ; <some commands>"

Greetings from Switzerland
Happl

Winke-Winke
Happl

 
 
 

1. Question about invoking rsh from ksh

I work in ksh. When a script invokes a remote shell using rsh where does
it get its environment from ? For e.g., if I do

$ rsh <remote host> env

why does it grab the stuff out of some minimal default env file instead
of sourcing my .profile or .kshrc. How do I get around this ? I want to
run a script which forks another shell but goes to that machine and uses
my own .profile or .kshrc.

I don't really want to do the following:

$ rsh <remote host> -l <userid> -e . .kshrc

You see, C shell sources your .cshrc every time it forks a shell but for
some reason ksh doesn't. Do you know a work around ?

I DO NOT want to modify my script to read an environment file somewhere.

thanks,
shivi shankaran.

2. How do I get the full length hostname?

3. ksh / rsh question

4. Ports upgrade

5. Matrox Mystique ands X.

6. Help! DTC3150V and problems loading off the CD-ROM

7. trouble with rsh and /bin/ksh

8. Java in X

9. starting script file with ksh for rsh commands

10. ksh over rsh startup script?

11. rsh, ksh & dot files

12. Bug in ksh when executed by rsh???

13. rsh/ksh problem