[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

.profile in UNIX

Bob Smyph

12/18/2008 6:35:00 PM

Does anyone know how to access and use the .profile in UNIX while using
NET::SSH in Ruby?

Thanks for the help
--
Posted via http://www.ruby-....

9 Answers

Bob Smyph

12/18/2008 6:48:00 PM

0

Tim Greer wrote:
>
> How to you mean? By updating it, parsing it from the file itself, or by
> using finger, or?

I believe we just need to load it into the session/channel so that we
can use access/use command associated with the .profile

We are trying to run a command through Ruby but it seems that we need
certain environmental properties set (e.g. .profile) in order to do
this. If we log onto the server through Putty this command works just
fine.
--
Posted via http://www.ruby-....

Tim Greer

12/18/2008 6:49:00 PM

0

Bob Smyph wrote:

> Does anyone know how to access and use the .profile in UNIX while
> using NET::SSH in Ruby?
>
> Thanks for the help

How to you mean? By updating it, parsing it from the file itself, or by
using finger, or?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Bob Smyph

12/18/2008 6:56:00 PM

0

Tim Greer wrote:
>
> Sorry, I got you. I read the post too quickly and for some reason I
> thought you said .plan (I should have known that sounded strange).
> Indeed, the .profile is only set to work with shell, in the shell env,
> which is why CGI, web server APIs/modules and rails don't read it. Did
> you need to set any environments or did you want to emulate or somehow
> use the shell vars naturally (assuming you can trust the
> user's .profile)?

If the only way to get this to work is to set the environment/variables
or emulate them somehow in the Ruby script, that is what we will need to
do. Any idea as how to do this?
--
Posted via http://www.ruby-....

Tim Greer

12/18/2008 7:00:00 PM

0

Bob Smyph wrote:

> Tim Greer wrote:
>>
>> How to you mean? By updating it, parsing it from the file itself, or
>> by using finger, or?
>
> I believe we just need to load it into the session/channel so that we
> can use access/use command associated with the .profile
>
> We are trying to run a command through Ruby but it seems that we need
> certain environmental properties set (e.g. .profile) in order to do
> this. If we log onto the server through Putty this command works just
> fine.

Sorry, I got you. I read the post too quickly and for some reason I
thought you said .plan (I should have known that sounded strange).
Indeed, the .profile is only set to work with shell, in the shell env,
which is why CGI, web server APIs/modules and rails don't read it. Did
you need to set any environments or did you want to emulate or somehow
use the shell vars naturally (assuming you can trust the
user's .profile)?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

ara.t.howard

12/19/2008 2:52:00 AM

0


On Dec 18, 2008, at 11:35 AM, Bob Smyph wrote:

> Does anyone know how to access and use the .profile in UNIX while
> using
> NET::SSH in Ruby?
>
> Thanks for the help


you need to invoke a login shell on the remote host, then
your .profile will be sourced.

probably there is some option to specify the remote shell for
Net::SSH, specify something like

'/bin/bash --login'

alternatively wrap your commands in something that does this for you
like

cfp:~ > cat `which bashenv`
#!/bin/bash --login
exec "$@"


and then invoke commands like 'bashenv something.exe'


a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Rodrigo Bermejo

12/19/2008 5:47:00 PM

0

Bob Smyph wrote:
> Tim Greer wrote:
>>
>> Sorry, I got you. I read the post too quickly and for some reason I
>> thought you said .plan (I should have known that sounded strange).
>> Indeed, the .profile is only set to work with shell, in the shell env,
>> which is why CGI, web server APIs/modules and rails don't read it. Did
>> you need to set any environments or did you want to emulate or somehow
>> use the shell vars naturally (assuming you can trust the
>> user's .profile)?
>
> If the only way to get this to work is to set the environment/variables
> or emulate them somehow in the Ruby script, that is what we will need to
> do. Any idea as how to do this?

You can 'source' the .profile in your ssh session doing a:
cmd=". /home/user/.profile"

note the space after the dot.

Regards.
--
Posted via http://www.ruby-....

Rob Biedenharn

12/19/2008 6:26:00 PM

0

On Dec 19, 2008, at 12:47 PM, Rodrigo Bermejo wrote:
> Bob Smyph wrote:
>> Tim Greer wrote:
>>>
>>> Sorry, I got you. I read the post too quickly and for some reason I
>>> thought you said .plan (I should have known that sounded strange).
>>> Indeed, the .profile is only set to work with shell, in the shell
>>> env,
>>> which is why CGI, web server APIs/modules and rails don't read
>>> it. Did
>>> you need to set any environments or did you want to emulate or
>>> somehow
>>> use the shell vars naturally (assuming you can trust the
>>> user's .profile)?
>>
>> If the only way to get this to work is to set the environment/
>> variables
>> or emulate them somehow in the Ruby script, that is what we will
>> need to
>> do. Any idea as how to do this?
>
> You can 'source' the .profile in your ssh session doing a:
> cmd=". /home/user/.profile"
>
> note the space after the dot.
>
> Regards.


Read the docs about the intended use and behavior of ~/.profile or
~/.login or ~/.bash_login compared to ~/.bashrc

It's probably in the INVOCATION section of the manual for your shell.


-Rob

Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com



Gerardo Santana Gómez Garrido

12/19/2008 6:28:00 PM

0

On Thu, Dec 18, 2008 at 12:48 PM, Bob Smyph
<eric.ramsey@cbc-companies.com> wrote:
> Tim Greer wrote:
>>
>> How to you mean? By updating it, parsing it from the file itself, or by
>> using finger, or?
>
> I believe we just need to load it into the session/channel so that we
> can use access/use command associated with the .profile
>
> We are trying to run a command through Ruby but it seems that we need
> certain environmental properties set (e.g. .profile) in order to do
> this. If we log onto the server through Putty this command works just
> fine.
> --
> Posted via http://www.ruby-....
>
>

If your server is running OpenSSH, you can also use ~/.ssh/environment.

See sshd(8) for details, under the LOGIN PROCESS section:

http://www.openbsd.org/cgi-bin/man.cgi?query=sshd&...

--
Gerardo Santana

Bob Smyph

12/19/2008 7:24:00 PM

0

Thanks to all the help. We took some of your suggessions and some of our
own hacking and got this to work.

thanks
--
Posted via http://www.ruby-....