[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

net-ssh and remote shell

unbewusst.sein

7/27/2008 9:28:00 AM


following the page :
<http://drnicwilliams.com/2006/09/22/remote-shell-with...

i've uninstalled net-ssh and the like then,
intall needle-1.3.0.gem
and re-installed :
net-ssh-2.0.3.gem
net-scp-1.0.1.gem
net-ssh-gateway-1.0.0.gem
net-ssh-multi-1.0.0.gem

after that, i wanted to test a small piece of code :
------------------------------------------------------------------------
#! /usr/bin/env ruby

require 'rubygems'
require 'needle'
require 'net/ssh'
require 'lib/preferences' # gives the options
require 'lib/tt_check' # gives tt_connected? (verify the USB-lan is
connected)

if tt_connected?
result=""
session=Net::SSH.start("TT", "root", options)
shell=session.shell.sync ### <<<=== line 13
out=shell.send_command 'ls -lart'
puts out.stdout
else
puts "Twin-Tact is not connected."
end
------------------------------------------------------------------------

and i got :
$ ./ssh_shell_sync.rb
../ssh_shell_sync.rb:13: undefined method `shell' for
#<Net::SSH::Connection::Session:0x16b4fd0> (NoMethodError

then, i wonder if there is a special way to install net-ssh to let it
take into account "Needle" ???
--
Une Bévue
25 Answers

90kts

7/28/2008 8:44:00 AM

0

Your code example works with net-shh 1.1.2 but not 2.0.3

For this sort of thing I prefer to use the .exec method and store all
output in an array:

require 'rubygems'
require 'needle'
require 'net/ssh'
session=Net::SSH.start("localhost",
"90kts", :password=>"**************")
cmd = 'ls -lart'
out = []
out = session.exec!(cmd).split(/\n/)
puts out

Hope that helps =)

unbewusst.sein

7/28/2008 10:00:00 AM

0

90kts <koops@90kts.com> wrote:

> For this sort of thing I prefer to use the .exec method and store all
> output in an array:
>
> require 'rubygems'
> require 'needle'
> require 'net/ssh'
> session=Net::SSH.start("localhost",
> "90kts", :password=>"**************")
> cmd = 'ls -lart'
> out = []
> out = session.exec!(cmd).split(/\n/)
> puts out
>
> Hope that helps =)

yes fine !

what is the usefullness of "needle" here ?

I've installed it, but don't know how to verify net/ssh makes use of
it...

also, I'm unable to have a command with "cd /some/path"

cd is a built-in, i think that's the prob.
--
Une Bévue

unbewusst.sein

7/28/2008 10:06:00 AM

0

Une Bévue <unbewusst.sein@weltanschauung.com.invalid> wrote:

> also, I'm unable to have a command with "cd /some/path"
>
> cd is a built-in, i think that's the prob.

for example, with :
session.exec!("cd /mnt/fat;ls -Al")

i get :
exec: 4: cd: not found

???
--
Une Bévue

90kts

7/28/2008 11:19:00 AM

0

On Jul 28, 8:06 pm, unbewusst.s...@weltanschauung.com.invalid (Une
Bévue) wrote:
> Une Bévue <unbewusst.s...@weltanschauung.com.invalid> wrote:
> > also, I'm unable to have a command with "cd /some/path"
>
> > cd is a built-in, i think that's the prob.
>
> for example, with :
> session.exec!("cd /mnt/fat;ls -Al")
>
> i get :
> exec: 4: cd: not found
>
> ???
> --
> Une Bévue

needle is a dependency, it will complain if you try and install net-
ssh without it.
for your example, just do this:
session.exec!("ls -Al /mnt/fat")

unbewusst.sein

7/28/2008 1:36:00 PM

0

90kts <koops@90kts.com> wrote:

>
> needle is a dependency, it will complain if you try and install net-
> ssh without it.

not sure about that point because i did two installs the first without
needle, i've uninstalled afterwards, install needle, and re-install
net/ssh.
no visible differences ???

> for your example, just do this:
> session.exec!("ls -Al /mnt/fat")

yes, of course, it was only an example.
--
Une Bévue

90kts

7/28/2008 11:59:00 PM

0

On Jul 28, 11:36 pm, unbewusst.s...@weltanschauung.com.invalid (Une
Bévue) wrote:
> 90kts <ko...@90kts.com> wrote:
>
> > needle is a dependency, it will complain if you try and install net-
> > ssh without it.
>
> not sure about that point because i did two installs the first without
> needle, i've uninstalled afterwards, install needle, and re-install
> net/ssh.
> no visible differences ???
>
> > for your example, just do this:
> > session.exec!("ls -Al /mnt/fat")
>
> yes, of course, it was only an example.
> --
> Une Bévue

Does it not automatically install dependencies by default?

When I install from a local gem (no connection to internet) it will
complain that it doesn't have the required dependency (needle)

Try installing with --ignore-dependencies and see what happens...
Anyhoo ..

unbewusst.sein

7/29/2008 12:44:00 PM

0

90kts <koops@90kts.com> wrote:

>
> Does it not automatically install dependencies by default?
>
> When I install from a local gem (no connection to internet) it will
> complain that it doesn't have the required dependency (needle)

Quiest frankly i don't remember that point...
If i remember well i've installed net/ssh from local gems without needle
the first time.

--
Une Bévue

Henry Goodman

6/16/2011 1:30:00 PM

0

"lee" <schotness@gmail.com> wrote in message
news:61ffc23f-2edc-4eaa-8713-442b278edf75@v11g2000prk.googlegroups.com...
On Jun 3, 6:20 am, Joe Bruno <ajta...@att.net> wrote:
> Having had my first contact with computers in the 1980s, I'm somewhat
> computer illiterate.
>
> I want to change the font size on websites like this one.Any advice?

You could just hold the ctrl key & use your mouse scroll wheel to
adjust the page to your preferred viewing size

___________________________________________________

Thanks Lee. I never knew you could do that.
Doesn't work on email and newsgroups though, with Windows Mail.

--
Henry Goodman
henry dot goodman at virgin dot net


sheldonlg

6/16/2011 1:34:00 PM

0

On 6/16/2011 9:30 AM, Henry Goodman wrote:
> "lee" <schotness@gmail.com> wrote in message
> news:61ffc23f-2edc-4eaa-8713-442b278edf75@v11g2000prk.googlegroups.com...
> On Jun 3, 6:20 am, Joe Bruno <ajta...@att.net> wrote:
>> Having had my first contact with computers in the 1980s, I'm somewhat
>> computer illiterate.
>>
>> I want to change the font size on websites like this one.Any advice?
>
> You could just hold the ctrl key & use your mouse scroll wheel to
> adjust the page to your preferred viewing size
>
> ___________________________________________________
>
> Thanks Lee. I never knew you could do that.
> Doesn't work on email and newsgroups though, with Windows Mail.

Strange. It works on Firefox (thanks Lee), but not on Thunderbird ---
and both are from Mozilla.

--
Shelly

lee

6/16/2011 2:45:00 PM

0

On Jun 16, 2:33 pm, sheldonlg <sheldo...@thevillages.net> wrote:
> On 6/16/2011 9:30 AM, Henry Goodman wrote:
>
> > "lee" <schotn...@gmail.com> wrote in message
> >news:61ffc23f-2edc-4eaa-8713-442b278edf75@v11g2000prk.googlegroups.com...
> > On Jun 3, 6:20 am, Joe Bruno <ajta...@att.net> wrote:
> >> Having had my first contact with computers in the 1980s, I'm somewhat
> >> computer illiterate.
>
> >> I want to change the font size on websites like this one.Any advice?
>
> > You could just hold the ctrl key & use your mouse scroll wheel to
> > adjust the page to your preferred viewing size
>
> > ___________________________________________________
>
> > Thanks Lee. I never knew you could do that.
> > Doesn't work on email and newsgroups though, with Windows Mail.
>
> Strange.  It works on Firefox (thanks Lee), but not on Thunderbird ---
> and both are from Mozilla.
>
> --
> Shelly

Its very confusing when dont know you can do it & do it inadvertently,
& then you dont know how to reverse it. Incidentally it works on
windows 7 desktop icons & other stuff, now too, if you like that sort
of thing..