# Newbie :: Running script at client side

**URL:** <https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119>\
**Category:** Rails\
**Created:** [April 16, 2007, 11:38am UTC](https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119 "2007-04-16T11:38:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 16, 2007, 11:38am UTC](https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119/1 "2007-04-16T11:38:39Z")

</div>

Hi all,  
I am newbie to Ruby and web programming as well.  
My show.rhtml is like,  
.  
…  
…  
\<% require ‘win32ole’ %\>  
\<% ie = WIN32OLE.new(‘InternetExplorer.Application’) %\>  
\<% ie.visible = true %\>  
\<% ie.gohome %\>  
…  
…  
.

At server, when I access http://…/show it’ll open Iexplorer.exe as  
expected,  
but when I access same from different m/c it opens Iexplorer.exe at  
server only,  
obviously. How can open it on client side?  
Please help me out.  
Thanks

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 16, 2007, 12:50pm UTC](https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119/2 "2007-04-16T12:50:59Z")

</div>

Rahul Ha wrote:

> Hi all,  
> I am newbie to Ruby and web programming as well.  
> My show.rhtml is like,  
> .  
> …  
> …  
> \<% require ‘win32ole’ %\>  
> \<% ie = WIN32OLE.new(‘InternetExplorer.Application’) %\>  
> \<% ie.visible = true %\>  
> \<% ie.gohome %\>  
> …  
> …  
> .
> 
> At server, when I access http://…/show it’ll open Iexplorer.exe as  
> expected,  
> but when I access same from different m/c it opens Iexplorer.exe at  
> server only,  
> obviously. How can open it on client side?  
> Please help me out.  
> Thanks

No Way.  
First, Browsers don’t allow the servers to execute code outside of their  
of their own application (security reasons). This is especially true for  
starting other applications.

Consider this:

\<% Â´format d:Â´ %\> 😉

Second, chances are high that the client does not have ruby installed…  
😉

Third, rhtml templates parse every bit of ruby inside your template, so  
it will only be executed on your side.

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 16, 2007, 1:15pm UTC](https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119/3 "2007-04-16T13:15:29Z")

</div>

Thanks,  
So, you want say that, if I want to open a PDF file stored on server, I  
need to download it first, and then open.  
How can open a PDF/Document in browser from client m/c?  
Regards,

> No Way.  
> First, Browsers don’t allow the servers to execute code outside of their  
> of their own application (security reasons). This is especially true for  
> starting other applications.
> 
> Consider this:
> 
> \<% Â´format d:Â´ %\> 😉
> 
> Second, chances are high that the client does not have ruby installed…  
> 😉
> 
> Third, rhtml templates parse every bit of ruby inside your template, so  
> it will only be executed on your side.

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 16, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119/4 "2007-04-16T16:49:57Z")

</div>

And, besides the obvious security problems involved in that, you would  
be making your web based application platform specific. That’s never  
a good thing.

On Apr 16, 6:50 am, Florian G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 16, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/newbie-running-script-at-client-side/92119/5 "2007-04-16T16:22:53Z")

</div>

> How can open a PDF/Document in browser from client m/c?  
> Regards,

try opening the pdf file as binary data and send it with the  
‘send\_data’ function to the browser.  
[http://railsapi.org/send\_data](http://railsapi.org/send_data)

something like that should do the trick:

mime\_type = ‘application/pdf’  
filename = ‘filename’  
extension = ‘pdf’  
send\_data(function\_to\_get\_the\_pdf\_as\_binary, :filename =\>  
“#{filename}.#{extension}”, :type =\> mime\_type, :disposition =\>  
‘inline’)

calling this function should send the pdf to the browser. than you  
have a sercer side stored pdf opened on client.  
don’t know if there’s a better way. never used server stored pdf’s  
with RoR. so perhaps somebody else can tell you a better way.

regards
