Re: [JSch-users] JSch Exec and the remote users environment
Status: Alpha
Brought to you by:
ymnk
|
From: Heiner W. <Hei...@He...> - 2007-03-28 07:38:57
|
Hello!
sshexec does not open a login shell, thus .profile, or .bash_profile, or
.login (I think tcsh reads this on login) are ignored.
Since I usualy want the same PATH and other environment in login- and non-interactive shells, I put my PATH setup in .bash_profile and source it from .bashrc (which is read by a non-login bash, but ignored by login bash).
Like so:
in .bash_profile:
PATH="/my/pre/path:${PATH}:/my/post/path"; export PATH
# Tell bashrc that profile has been sourced
PROFILE_SOURCED=1; export PROFILE_SOURCED
. ~/.bashrc
in .bashrc:
if test -z "$PROFILE_SOURCED"; then
. /etc/profile
. ~/.bash_profile
fi
A similar approach should do for .tcshrc and .login, if you are using tcsh.
Can't remember, if the plain old bourne shell has two setup files.
HTH,
Heiner
Boris Klug schrieb:
> Hi!
>
> I think the PATH is not set up. Here on my system (AIX) the PATH and
> other shell variables are set up in the file ".profile". You have to
> execute it before you execute your command.
> E.g. if you want to execute "ls" you have to execute this:
>
> source .profile > /dev/null; ls
>
> This should work.
>
> J.D. Ray schrieb:
>> Hi again.
>>
>> I've put together a class to remotely execute a command using JSch,
>> using the exec.java example heavily for guidance. It seems to work
>> fine, except that the commands (including the basics like "ls" and
>> "echo") have to be fully pathed to work ("/bin/ls", etc.). Is there
>> some option that I'm missing, some setting in the session?
>>
>> Thanks.
>>
>> JD
>>
>> --
>> http://somethingstirring.blogspot.com/
>>
>> If you don't stir the pot,
>> the stuff at the bottom just sits there.
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share your
>> opinions on IT & business topics through brief surveys-and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> JSch-users mailing list
>> JSc...@li...
>> https://lists.sourceforge.net/lists/listinfo/jsch-users
>
|