Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Invoking a windows application (e.g notepad) from ruby

Reply
Thread Tools

Invoking a windows application (e.g notepad) from ruby

 
 
Anukul Singhal
Guest
Posts: n/a
 
      03-19-2008
Hi,

I wanted to know if there is any utility present in ruby through which
we can invoke an external windows app (notepad.exe) or any exe.

Can anyone please help me with the relevant code in ruby which can do
so?

Thanks,
Anukul
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Siep Korteling
Guest
Posts: n/a
 
      03-19-2008
Anukul Singhal wrote:
> Hi,
>
> I wanted to know if there is any utility present in ruby through which
> we can invoke an external windows app (notepad.exe) or any exe.
>
> Can anyone please help me with the relevant code in ruby which can do
> so?
>
> Thanks,
> Anukul


The short way:


`notepad`

Note these are backticks, not single quotes. Ruby will wait until
notepad is finished. If the waiting is not desired, this is an option:

system("start notepad")
system("calc")

Possibly you have to provide the full path to the executable.

Regards,

Siep


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jano Svitok
Guest
Posts: n/a
 
      03-19-2008
On Wed, Mar 19, 2008 at 11:42 PM, Anukul Singhal
<(E-Mail Removed)> wrote:
> Hi,
>
> I wanted to know if there is any utility present in ruby through which
> we can invoke an external windows app (notepad.exe) or any exe.
>
> Can anyone please help me with the relevant code in ruby which can do
> so?


if you want to wait until the program finishes:
system "notepad"
if you don't want:
system "start notepad"

see also Kernel#`

note that if you need to quote the program name, you have to add
another pair of quotes, because start
threats the first quoted string as window title.

system 'start "" "C:\Program Files\whaterver.exe"'

 
Reply With Quote
 
Anukul Singhal
Guest
Posts: n/a
 
      03-20-2008
Siep Korteling wrote:
> Anukul Singhal wrote:
>> Hi,
>>
>> I wanted to know if there is any utility present in ruby through which
>> we can invoke an external windows app (notepad.exe) or any exe.
>>
>> Can anyone please help me with the relevant code in ruby which can do
>> so?
>>
>> Thanks,
>> Anukul

>
> The short way:
>
>
> `notepad`
>
> Note these are backticks, not single quotes. Ruby will wait until
> notepad is finished. If the waiting is not desired, this is an option:
>
> system("start notepad")
> system("calc")
>
> Possibly you have to provide the full path to the executable.
>
> Regards,
>
> Siep


----------------------------------------

Siep, Thanks a lot!!

..Anukul
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Anukul Singhal
Guest
Posts: n/a
 
      03-20-2008
Jano Svitok wrote:
> On Wed, Mar 19, 2008 at 11:42 PM, Anukul Singhal
> <(E-Mail Removed)> wrote:
>> Hi,
>>
>> I wanted to know if there is any utility present in ruby through which
>> we can invoke an external windows app (notepad.exe) or any exe.
>>
>> Can anyone please help me with the relevant code in ruby which can do
>> so?

>
> if you want to wait until the program finishes:
> system "notepad"
> if you don't want:
> system "start notepad"
>
> see also Kernel#`
>
> note that if you need to quote the program name, you have to add
> another pair of quotes, because start
> threats the first quoted string as window title.
>
> system 'start "" "C:\Program Files\whaterver.exe"'


---------------------------------------

Jano, thanks a lot!

..Anukul

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoking Perl Module from Ruby SS Ruby 1 08-27-2009 04:42 PM
Invoking Ruby code from a low-level language? Alex Fulton Ruby 10 12-16-2008 11:54 PM
invoking a java application by name LC's No-Spam Newsreading account Java 7 02-27-2007 01:28 PM
Invoking a batch file with Ruby on Windows brian.kejser@protexis.com Ruby 1 08-21-2006 12:04 AM
Invoking another instance of the same application,saving/restoring session state usl2222@yahoo.com ASP .Net 1 01-12-2004 05:04 PM



Advertisments