I need a ruby script that converts the contents of the clipboard to the md5 sum of the contents of the clipboard

It is all in the subject line.

I want to copy something.

Click on this script
the scipts performs an md5sum of what is on the clipboard and REPLACES it with just it's md5sum.

:)

thx  
TIMFOX123Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
JESiiConnect With a Mentor Commented:
No problem; just change line 13 from:
     Clipboard.set_data(hash)
to use string concatenation to read:
     Clipboard.set_data('./fixit_' + hash + '.sh')

Alternatively, you could use string interpolation to do:
     Clipboard.set_data("./fixit_#{hash}.sh")

I've seen some comments that say string interpolation is faster, but in this case I don't think speed of execution could possibly be an issue, so use whichever feels most comfortable to you.
0
 
JESiiCommented:
Try this
#!/usr/env ruby

require 'digest/md5'

require 'Win32API'
require 'win32/clipboard'
include Win32

data = Clipboard.get_data

hash = Digest::MD5.hexdigest(data)

Clipboard.set_data(hash)

Open in new window

0
 
TIMFOX123Author Commented:
Jessi

in `require': no such file to load -- win32/clipboard (LoadError)

Please refresh the mind of an old man .... :)

I have to run someting at the command line to get this code.  

thx.  
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
TIMFOX123Author Commented:
I am running rubymine :)

0
 
JESiiCommented:
Of course; sorry... been a while, but as I recall you'll need:
     gem install win32-api
You may also need:
     gem install win32-clipboard

You can run this from the command line or within rubymine...
     
0
 
TIMFOX123Author Commented:
Jessii

I am still working this issue.   I am sure you gave good code, I just can not get my ruby mine to run it.  ( can not get it to see the gem ).  Rubymine has the best support in the sub 100$ software so I have pinged them.  

I am not ignoring this, I am just working the last step out with rubymine because it is not your issue.  

0
 
JESiiCommented:
I know what you mean; I've had some issues with RubyMine and gems, but they generally are responsive.

You might try just running this stand alone and make sure that you can get the basics running, and then you'll have a more complete bug report to the RM folks. I ran mine on Cygwin from the command line.
0
 
TIMFOX123Author Commented:
Jesii

can you give me a 101 on how to hand compile this ?

I am working the issue with rubygems but want to get this going.
Also this would be great for sending it to other desktops !!

0
 
JESiiCommented:
Sure... try this:
1. Create the file as 'clipboard.rb' in your working directory
2. gem install win32-api
3. gem install win32-clipboard
4. ruby clipboard.rb

Whatever was in the clipboard will now be hashed....
0
 
TIMFOX123Author Commented:
Jesii
this really is exciting ( I need this for deployment )

tell me more about:
2. gem install win32-api
3. gem install win32-clipboard

that will install it to the wrong place ?????  !!

so I put your script and the output of gem install in a directory and "life is good !!:
0
 
TIMFOX123Author Commented:
H:\rubypaste>gem install win32-api
ERROR:  Could not find a valid gem 'win32-api' (>= 0) in any repository
0
 
JESiiCommented:
Strange; try:
     gem search win32
and see what you get.
0
 
TIMFOX123Author Commented:
Jessi
great job and I am ready to award you all the points.  

One last question.  
I want to "prepend" the md5sum in the clipboard.
Lets say the md5sum is    2341234 and it is in the clipboard.
I want the clipboard to now have  ./fixit_ 2341234

Thank you soooooo much.


0
 
TIMFOX123Author Commented:
corection:

 ./fixit_ 2341234.sh  

 

0
 
TIMFOX123Author Commented:
thank you so much.

If you know it or not, you create a sudo-database with this code that will be doing fixes on a large network.  Thank you soooooo much.

As I have said to other EE experts, you make me look really good.

thx so much.  
0
 
TIMFOX123Author Commented:
this really works and really rocks.

I am using the md5sum of an error string to create a number.  The number is the shell file that fixes it
0
 
JESiiCommented:
You are very welcome; glad I could help!  And thank you for the points...
0
All Courses

From novice to tech pro — start learning today.