ssh, non-interactive, ksh shell environment - SSH

This is a discussion on ssh, non-interactive, ksh shell environment - SSH ; I cannot figure out how to get the environment setup correctly for the connection I'm making with PuTTY's plink application. With putty, I saved a session from an ssh connection; it includes the username to connect as and the path ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: ssh, non-interactive, ksh shell environment

  1. ssh, non-interactive, ksh shell environment

    I cannot figure out how to get the environment setup correctly for the
    connection I'm making with PuTTY's plink application. With putty, I
    saved a session from an ssh connection; it includes the username to
    connect as and the path to the private key file to use for
    authentication. So when I connect interactively with putty, using the
    saved session, I don't need to provide a username or password, I'm
    automatically connected as the saved user and the expected environment
    variables and values exist. The shell is ksh. When I connect with
    plink, non-interactively, using the same "saved session", I just need
    to run one command (a ksh script). It is still connecting as the
    saved user (at least $HOME is the expected value and a plink message
    says "Using username abc".) but the enironment is not set as it was
    with the putty connection; which means the script fails.

    The environment settings that I need are set in the user's .profile
    file, so I think the "saved session" might be treated as a login
    invocation of ksh, at least through putty. But obviously .profile is
    not being sourced when I connect with plink. Any ideas on what
    startup files are being sourced when I connect with plink this way?
    What files could I create or edit so that the saved username
    user's .profile is sourced when I connect with plink? Or do I need to
    duplicate (or move) the settings I care about to a more global startup
    file?


  2. Re: ssh, non-interactive, ksh shell environment

    schrieb im Newsbeitrag
    news:1181231165.280309.175480@g4g2000hsf.googlegro ups.com...
    >I cannot figure out how to get the environment setup correctly for the
    > connection I'm making with PuTTY's plink application. With putty, I
    > saved a session from an ssh connection; it includes the username to
    > connect as and the path to the private key file to use for
    > authentication. So when I connect interactively with putty, using the
    > saved session, I don't need to provide a username or password, I'm
    > automatically connected as the saved user and the expected environment
    > variables and values exist. The shell is ksh. When I connect with
    > plink, non-interactively, using the same "saved session", I just need
    > to run one command (a ksh script). It is still connecting as the
    > saved user (at least $HOME is the expected value and a plink message
    > says "Using username abc".) but the enironment is not set as it was
    > with the putty connection; which means the script fails.
    >
    > The environment settings that I need are set in the user's .profile
    > file, so I think the "saved session" might be treated as a login
    > invocation of ksh, at least through putty. But obviously .profile is
    > not being sourced when I connect with plink. Any ideas on what
    > startup files are being sourced when I connect with plink this way?
    > What files could I create or edit so that the saved username
    > user's .profile is sourced when I connect with plink? Or do I need to
    > duplicate (or move) the settings I care about to a more global startup
    > file?

    I think non-login shells don't go throug any startup files, neither local
    like .profile nor global like /etc/profile.
    Korn-Shells (every, not just the initial login shell) source in a file named
    in $ENV, maybe you can cause plink to have that variable passed to the shell
    it starts?

    Bye, Jojo



  3. Re: ssh, non-interactive, ksh shell environment

    schrieb im Newsbeitrag
    news:1181231165.280309.175480@g4g2000hsf.googlegro ups.com...
    >I cannot figure out how to get the environment setup correctly for the
    > connection I'm making with PuTTY's plink application. With putty, I
    > saved a session from an ssh connection; it includes the username to
    > connect as and the path to the private key file to use for
    > authentication. So when I connect interactively with putty, using the
    > saved session, I don't need to provide a username or password, I'm
    > automatically connected as the saved user and the expected environment
    > variables and values exist. The shell is ksh. When I connect with
    > plink, non-interactively, using the same "saved session", I just need
    > to run one command (a ksh script). It is still connecting as the

    Can't you source in .profile inside that script?

    > saved user (at least $HOME is the expected value and a plink message
    > says "Using username abc".) but the enironment is not set as it was
    > with the putty connection; which means the script fails.
    >
    > The environment settings that I need are set in the user's .profile
    > file, so I think the "saved session" might be treated as a login
    > invocation of ksh, at least through putty. But obviously .profile is
    > not being sourced when I connect with plink. Any ideas on what
    > startup files are being sourced when I connect with plink this way?
    > What files could I create or edit so that the saved username
    > user's .profile is sourced when I connect with plink? Or do I need to
    > duplicate (or move) the settings I care about to a more global startup
    > file?

    Or get plink to do 2 commands ". ~/.profile; my_ksh_script"

    Bye, Jojo



  4. Re: ssh, non-interactive, ksh shell environment

    On Jun 7, 1:08 pm, "Joachim Schmitz"
    wrote:
    > schrieb im Newsbeitragnews:1181231165.280309.175480@g4g2000hs f.googlegroups.com...>I cannot figure out how to get the environment setup correctly for the
    > > connection I'm making with PuTTY's plink application. With putty, I
    > > saved a session from an ssh connection; it includes the username to
    > > connect as and the path to the private key file to use for
    > > authentication. So when I connect interactively with putty, using the
    > > saved session, I don't need to provide a username or password, I'm
    > > automatically connected as the saved user and the expected environment
    > > variables and values exist. The shell is ksh. When I connect with
    > > plink, non-interactively, using the same "saved session", I just need
    > > to run one command (a ksh script). It is still connecting as the

    >
    > Can't you source in .profile inside that script?
    >
    > > saved user (at least $HOME is the expected value and a plink message
    > > says "Using username abc".) but the enironment is not set as it was
    > > with the putty connection; which means the script fails.

    >
    > > The environment settings that I need are set in the user's .profile
    > > file, so I think the "saved session" might be treated as a login
    > > invocation of ksh, at least through putty. But obviously .profile is
    > > not being sourced when I connect with plink. Any ideas on what
    > > startup files are being sourced when I connect with plink this way?
    > > What files could I create or edit so that the saved username
    > > user's .profile is sourced when I connect with plink? Or do I need to
    > > duplicate (or move) the settings I care about to a more global startup
    > > file?

    >
    > Or get plink to do 2 commands ". ~/.profile; my_ksh_script"
    >
    > Bye, Jojo


    Yes, I was hoping there was a simple option I didn't know about. What
    you suggested works, ". ~/.profile; script.ksh". Thank you. Since I
    don't own the script development, I'll send "~/.profile; ..." - though
    I think your first suggestion, to include it in the script, is a
    better practice if the intention is to allow other systems to run it;
    that way the script is not assuming a certain type of shell
    invocation. Thanks again.


  5. Re: ssh, non-interactive, ksh shell environment

    At 2007-06-07 04:21PM, "mtmcclellan@juno.com" wrote:
    [...]
    > Yes, I was hoping there was a simple option I didn't know about. What
    > you suggested works, ". ~/.profile; script.ksh". Thank you. Since I
    > don't own the script development, I'll send "~/.profile; ..." - though

    [...]

    Careful: the dot is the critical part -- it's the ksh "source" command.

    Do: ". ~/.profile; ..."
    NOT: "~/.profile; ..."

    --
    Glenn Jackman
    "You can only be young once. But you can always be immature." -- Dave Barry

+ Reply to Thread