Pasing data between 2 win XP boxes via internet

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.

On 26.12.2009 08:53, Dave L. wrote:

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). :wink:

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

Dave L. wrote:

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.

Phillip G. wrote:

On 26.12.2009 08:53, Dave L. wrote:

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). :wink:

[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.

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
[email protected]

Brian C. wrote:

Dave L. wrote:

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.

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.

Dave L. wrote:

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.

Simone D’Amico wrote:

Simone D’Amico
*nix powered
[email protected]

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 Y.

http://DevMentor.org

Do Good! - Share Freely

On Sat, Dec 26, 2009 at 9:03 AM, Rajinder Y. [email protected]
wrote:

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 :slight_smile:

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”

Hassan S. wrote:

result[2]
=> “Pretty cold”

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


Kind Regards,
Rajinder Y.

http://DevMentor.org

Do Good! - Share Freely

Dave L. wrote:

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

On 26.12.2009 13:01, Dave L. wrote:

Was hoping it’d be better news.

Well setting up an SSH server isn’t all that difficult.

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

Not at all, no. Never had the need to script PuTTY.

Dave L. wrote:

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).

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.

Bill K. wrote:

Dave L. wrote:

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

On 28.12.2009 06:06, Dave L. wrote:

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. :wink:

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. :wink:

Dave L. wrote:

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.

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.

Albert S. wrote:

Dave L. wrote:

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).

hi to all my friands

i joined to your group

please help

frist i should say my english has problem becoz im from iran

please help me in here:
http://www.ruby-forum.com/topic/201233#876255

becoz really i need that code

thank you

im sorry i given post here …

thanks all friands

Thank you very much.

Il giorno 26/dic/2009, alle ore 18.20, Hassan S. ha scritto:

result[2]
=> “Pretty cold”


Hassan S. ------------------------ [email protected]
twitter: @hassan

Simone D’Amico
*nix powered
[email protected]

Dave L. wrote:

Cheers Brian,

Learning more as the days go by.

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

There is also the commercial solution DropBox (and other similar ones).
DropBox is free for up to 2GB of storage, and I believe has Windows, Mac
and Linux clients.