pasing data between 2 win XP boxes via internet

D

Dave Lilley

Hi folks,

been trolling the net for a long time off and on but NOW i must get this
problem sorted.

I am needing to pass via the internet data from a Desktop PC to a Laptop
and vis versa in an adhoc manner.

I know i want to use net::SCP or one of the SSH family protocols, My
problem is i haven't been able to find a suitable sample code to look at
or use.

I believe my desktop program can be converted to work as a web app but
that is for a future iteration.

problem is currently.

how to pass a stream of data in a secure manner using SSH protocos from
a winXP Pro OS to a winXP Pro OS using 1.8.6.X ruby.

there won't be a "server" used for the present and so would like to push
data from one end to the other when the user has an update needed to be
passed on.

I am totally new to the net::XXXX protocols so any help would be
appreciated.

Dave.


PS any help in using PuTTy as an agent would be appreciated also as this
may help - again advise required.
 
P

Phillip Gawlowski

Hi folks,

been trolling the net for a long time off and on but NOW i must get this
problem sorted.

I am needing to pass via the internet data from a Desktop PC to a Laptop
and vis versa in an adhoc manner.

While not a Ruby solution:
Take a look at LogMeIn[0].

It might be enough for your needs.

Not a Ruby solution, either:
It'd be easy to setup an OpenSSH server on Windows[1] (one on each of
your machines), and simply use PuTTY, or WinSCP to transfer commands /
files.

Keep in mind: You *will* need a server/client combination. That's pretty
much required (even P2P networks are client/server, it's just that you
need only one program to do both, on the same port). ;)

[0] https://secure.logmein.com/US/products/free/
[1] http://sshwindows.sourceforge.net/
 
B

Brian Candler

Dave said:
I know i want to use net::SCP or one of the SSH family protocols, My
problem is i haven't been able to find a suitable sample code to look at
or use.

SSH is a client-server protocol. However, unless it has changed since I
lasted looked at it, Net::SSH only implements the client side of the
protocol. That is, you can't write a ruby program to receive inbound SSH
connections using this.

So you options are:

(1) Have a non-Ruby ssh server at one side of the connection. For
example, install cygwin on one of the machines.

(2) For a pure Ruby solution, use a non-SSH protocol. For example,
implement a simple web server using Sinatra at one side, and then
transfer files using GET and PUT from the other side (e.g. Net::HTTP or
RestClient, or even open-uri)

If you want this to be secure, then use HTTPS.
 
D

Dave Lilley

Phillip said:
Hi folks,

been trolling the net for a long time off and on but NOW i must get this
problem sorted.

I am needing to pass via the internet data from a Desktop PC to a Laptop
and vis versa in an adhoc manner.

While not a Ruby solution:
Take a look at LogMeIn[0].

It might be enough for your needs.

Not a Ruby solution, either:
It'd be easy to setup an OpenSSH server on Windows[1] (one on each of
your machines), and simply use PuTTY, or WinSCP to transfer commands /
files.

Keep in mind: You *will* need a server/client combination. That's pretty
much required (even P2P networks are client/server, it's just that you
need only one program to do both, on the same port). ;)

[0] https://secure.logmein.com/US/products/free/
[1] http://sshwindows.sourceforge.net/

Hi Phillip,

thanks for your reply,

Was hoping it'd be better news.
Oh well I'll have to look at PuTTy then.

Are you able to help with Putty & ruby or plink?

cheers,

Dave.
 
D

Dave Lilley

Brian said:
SSH is a client-server protocol. However, unless it has changed since I
lasted looked at it, Net::SSH only implements the client side of the
protocol. That is, you can't write a ruby program to receive inbound SSH
connections using this.

So you options are:

(1) Have a non-Ruby ssh server at one side of the connection. For
example, install cygwin on one of the machines.

(2) For a pure Ruby solution, use a non-SSH protocol. For example,
implement a simple web server using Sinatra at one side, and then
transfer files using GET and PUT from the other side (e.g. Net::HTTP or
RestClient, or even open-uri)

If you want this to be secure, then use HTTPS.

Brian,

Many thanks for the help.
Can you help with a PuTTy (plink & ruby) connection?

my main issue is I am under windows unsure of the PC's hostname.

IE is the hostname = to the PC name (with linux localhost = hostname for
the box your on).

regards,

Dave.
 
S

Simone D'Amico

Hello guys,
I have to parse a file of questions/answers for a quizbot in ruby.
The file is structured in this way:
"Question" "Answer"\r\n
"Question2" "Answer2"\r\n
"Questionn" "Answern"\r\n

How to parse it efficacely?
Thank you in advance.



Simone D'Amico
*nix powered
(e-mail address removed)
 
B

Brian Candler

Dave said:
Can you help with a PuTTy (plink & ruby) connection?

I think PuTTY and plink are red herrings here.

PuTTY is a console ssh client: i.e. once the connection is established,
you have to type things into it at the keyboard, and it displays the
responses in a window. plink allows you to script the setting up of this
interactive session. Neither of these is an ssh server, and neither of
them would allow you to use ruby to send and receive data (unless you're
talking about forwarding a TCP connection through an ssh port-forwarding
tunnel, which I don't think you are).

As I said before, you first need to decide what you're attempting to do:
something using ssh, or something which is a pure Ruby solution like
HTTPS.

I actually think that ssh is a good solution - it's robust, secure and
well known / well trusted. But to do this, you'll need an ssh server on
one side - for example Cygwin.

Once you have this in place, you can use putty/pscp/psftp from the other
side to test it out. Then you can write a Ruby program which uses
Net::SSH or the corresponding scp / sftp modules to transfer files. You
wouldn't actually use putty from your script.

(At a push, you might able to script pscp.exe or psftp.exe from Ruby,
although you'd have to sort out authentication, either handling
interactive prompting for a password, or using public key authentication
with no passphrase on the private key)

Regards,

Brian.
 
R

Rajinder Yadav

Simone said:
Hello guys,
I have to parse a file of questions/answers for a quizbot in ruby.
The file is structured in this way:
"Question" "Answer"\r\n
"Question2" "Answer2"\r\n
"Questionn" "Answern"\r\n

How to parse it efficacely?
Thank you in advance.

Simone D'Amico
*nix powered
(e-mail address removed)

here is the basic code, output followed by a basic explanation

IO.foreach("testfile.txt") do |line|
data=line.match /\"(\w+)\"\s+\"(\w+)\"/
puts data[1] # question
puts data[2] # answer
end


[output]

Question
Answer
Question2
Answer2
Questionn
Answern


basic explanation: match returns a MatchData object, which can be
accessed like an array.

you will want to access the 2nd and 3rd position of the MatchData
object, the first (zero position) holds an array of the entire parsed
data set.

irb(main):337:0> str='"Question" "Answer"'

irb(main):338:0> data=str.match /\"(\w+)\"\s+\"(\w+)\"/

irb(main):339:0> data[0]
=> "\"Question\" \"Answer\""

irb(main):340:0> data[1]
=> "Question"

irb(main):341:0> data[2]
=> "Answer"


--
Kind Regards,
Rajinder Yadav

http://DevMentor.org

Do Good! - Share Freely
 
H

Hassan Schroeder

here is the basic code, output followed by a basic explanation
=A0 data=3Dline.match /\"(\w+)\"\s+\"(\w+)\"/

?? That won't remotely work, unless the "Question" and "Answer"
are both single words, which seems unlikely :)

Try something like line.chomp.match /\"([^"]+)\"\s+\"([^"]+)\"/
'"What is the temperature?" "Pretty cold"'.match /\"(\w+)\"\s+\"(\w+)\"/ =3D> nil
'"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+=
)\"/
=3D> #<MatchData "\"What is the temperature?\" \"Pretty cold\"" 1:"What
is the temperature?" 2:"Pretty cold">
result =3D '"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"=
\s+\"([^"]+)\"/
=3D> #<MatchData "\"What is the temperature?\" \"Pretty cold\"" 1:"What
is the temperature?" 2:"Pretty cold">
result[1] =3D> "What is the temperature?"
result[2] =3D> "Pretty cold"

--=20
Hassan Schroeder ------------------------ (e-mail address removed)
twitter: @hassan
 
R

Rajinder Yadav

Hassan said:
here is the basic code, output followed by a basic explanation
data=line.match /\"(\w+)\"\s+\"(\w+)\"/

?? That won't remotely work, unless the "Question" and "Answer"
are both single words, which seems unlikely :)

Try something like line.chomp.match /\"([^"]+)\"\s+\"([^"]+)\"/
'"What is the temperature?" "Pretty cold"'.match /\"(\w+)\"\s+\"(\w+)\"/ => nil
'"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+)\"/
=> #<MatchData "\"What is the temperature?\" \"Pretty cold\"" 1:"What
is the temperature?" 2:"Pretty cold">
result = '"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+)\"/
=> #<MatchData "\"What is the temperature?\" \"Pretty cold\"" 1:"What
is the temperature?" 2:"Pretty cold">
result[1] => "What is the temperature?"
result[2]
=> "Pretty cold"

I shouldn't reply when I am half awake =)

--
Kind Regards,
Rajinder Yadav

http://DevMentor.org

Do Good! - Share Freely
 
B

Bill Kelly

Dave said:
how to pass a stream of data in a secure manner using SSH protocos from
a winXP Pro OS to a winXP Pro OS using 1.8.6.X ruby.

there won't be a "server" used for the present and so would like to push
data from one end to the other when the user has an update needed to be
passed on.

I am totally new to the net::XXXX protocols so any help would be
appreciated.

Note, there's also OpenSSL::SSL::SSLSocket and OpenSSL::SSL::SSLServer
which should allow you to establish an encrypted connection between
two nodes at the TCP socket level.

That's a pretty low-level solution, in that you end up with a socket,
and you'll need to write code on either end to decide what to do with
data that is sent/received.

Depending on your needs, a higher level solution--as others have
mentioned--might be to install cygwin and get an ssh server running,
then use for example rsync to synchronize files and directories between
the nodes.


Hope this helps,

Bill
 
D

Dave Lilley

Hi Bill thanks for the reply,

I guess i will have to setup a SSH server on the PC as it will be the
central point for data being sent from and sent to.

thanks for your time in replying.

Dave.
 
A

Albert Schlef

Dave said:
I am needing to pass via the internet data from a Desktop PC to a Laptop
and vis versa in an adhoc manner.


Well, there's also the option of introducing a 3'rd computer: a server.
Your desktop sends the file there, and the laptop downloads it form
there (or vice versa).

That's basically how software upgrdes go (think RubyGems, SVN, etc).
 
D

Dave Lilley

Albert,

I won't be having a "PC server" well not for the present time being
anyway.

I was hoping i could "just" cause an event to happen which would linkup
with the other PC push the data down and then close the connection.

I wasn't sure at the start of my posting and the initial 2 replies just
comfirmed it for me.

well I'm now resigned to the fact of having a "server" sited on a PC.

cheers,

dave.
 
P

Phillip Gawlowski

Albert,

I won't be having a "PC server" well not for the present time being
anyway.

Install, for example, apache on Windows. Voilà, instant server, just add
firewall. ;)
I was hoping i could "just" cause an event to happen which would linkup
with the other PC push the data down and then close the connection.

If all you need is to get data (i.e. files) from A to B, take a look at
https://www.mesh.com/

While a tool to sync folders, it *can* get files from A to B.

If you need to fire a tool, then grab a tool that watches folders for
(changed) content, and use that to trigger what you need, like a Ruby
script parsing the data you sent over.
well I'm now resigned to the fact of having a "server" sited on a PC.

That's TCP/IP for you. ;)
 
B

Brian Candler

Dave said:
I was hoping i could "just" cause an event to happen which would linkup
with the other PC push the data down and then close the connection.

If that's all you want to do - sync directories between two machines
periodically - then don't reinvent the wheel, just install 'unison' and
be done with it:

http://www.cis.upenn.edu/~bcpierce/unison/

It can even sync between Windows<->Unix (I have a friend who does this).

To run unison over ssh, then I think the easiest way would be to install
cygwin on both sides and use the cygwin unison package (I presume there
is one).

unison is cool because, unlike rsync, it can sync bidirectionally. A
file created/edited/deleted on side A will be replicated to side B, and
vice versa.
 
D

Dave Lilley

Cheers Brian,

Learning more as the days go by.

I have heard of unison but didn't really know what it does :).

thanks.
 
S

Simone D'Amico

Thank you very much.

Il giorno 26/dic/2009, alle ore 18.20, Hassan Schroeder ha scritto:
here is the basic code, output followed by a basic explanation
data=line.match /\"(\w+)\"\s+\"(\w+)\"/

?? That won't remotely work, unless the "Question" and "Answer"
are both single words, which seems unlikely :)

Try something like line.chomp.match /\"([^"]+)\"\s+\"([^"]+)\"/
'"What is the temperature?" "Pretty cold"'.match /\"(\w+)\"\s+\"(\w+)\"/ => nil
'"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+)\"/
=> #<MatchData "\"What is the temperature?\" \"Pretty cold\"" 1:"What
is the temperature?" 2:"Pretty cold">
result = '"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+)\"/
=> #<MatchData "\"What is the temperature?\" \"Pretty cold\"" 1:"What
is the temperature?" 2:"Pretty cold">
result[1] => "What is the temperature?"
result[2] => "Pretty cold"



Simone D'Amico
*nix powered
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top