librelist archives

« back to archive

problem running system commands on windows from shoes app

problem running system commands on windows from shoes app

From:
Harsh Trivedi
Date:
2014-09-19 @ 05:45
Hello,

I have been making an app in Shoes, in which I need to run a system command:
eg. say my system command is
login_curl = 'curl ...'
I have tried it with many approaches like :
    IO.popen("#{login_curl}").gets
    system("#{login_curl}")
    `#{login_curl}`
    Open3.capture2("#{login_curl}")
    Open3.capture2e("#{login_curl}")
    Open3.capture3("#{login_curl}")

Each of the above approach works perfectly in linux,
and it works in windows also,
but my problem is that in Windows when i run the shoes app,
and whenever any of the above command is run,
a terminal window opens for a second and then closes itself.
(basically to run that 'login_curl' command on terminal)
I dont want my user to keep seeing a window terminal pop up
whenever system command is executed in shoes app on windows.

I am not at all used to windows and so need some help!

Thanx in advance :)

Re: [shoes] problem running system commands on windows from shoes app

From:
Carlos R. Tirado
Date:
2014-09-19 @ 16:17
Have you tried running your script on Windows not with ruby, but rubyw ?

Another possibility for suppressing the terminal window could be something
like:

%x{echo off; #{login_curl}; exit}
or %x{echo off; start #{login_curl}; exit}

I no longer have access to a Windows machine so I cannot test it myself.

HIH

ct.



On Thu, Sep 18, 2014 at 10:45 PM, Harsh Trivedi <harshjtrivedi94@gmail.com>
wrote:

> Hello,
>
> I have been making an app in Shoes, in which I need to run a system
> command:
> eg. say my system command is
> login_curl = 'curl ...'
> I have tried it with many approaches like :
>     IO.popen("#{login_curl}").gets
>     system("#{login_curl}")
>     `#{login_curl}`
>     Open3.capture2("#{login_curl}")
>     Open3.capture2e("#{login_curl}")
>     Open3.capture3("#{login_curl}")
>
> Each of the above approach works perfectly in linux,
> and it works in windows also,
> but my problem is that in Windows when i run the shoes app,
> and whenever any of the above command is run,
> a terminal window opens for a second and then closes itself.
> (basically to run that 'login_curl' command on terminal)
> I dont want my user to keep seeing a window terminal pop up
> whenever system command is executed in shoes app on windows.
>
> I am not at all used to windows and so need some help!
>
> Thanx in advance :)
>
>

Re: [shoes] problem running system commands on windows from shoes app

From:
Cecil Coupe
Date:
2014-09-20 @ 04:38
Rubyw is a clue to what's needed but that doesn't help existing Shoes.  
It seems like a good idea for Shoes/Windows.  Please file a bug report 
for Shoes 3.2 so the idea doesn't get lost.  Too soon to say how hard it 
will be to fix it.

As a workaround and if curl is what you need to run you can there are 
many things you can do with Ruby's http code that isn't in the Shoes 
download implementation.  Shoes 3.2 is a pretty complete Ruby so there 
is a lot there in the stdlib's. Documentation is pretty sparse for the 
http options, but it might do what you need curl for, assuming Shoes 
download doesn't work for you.

--Cecil
On 09/19/2014 10:17 AM, Carlos R. Tirado wrote:
> Have you tried running your script on Windows not with ruby, but rubyw ?
>
> Another possibility for suppressing the terminal window could be 
> something like:
>
> %x{echo off; #{login_curl}; exit}
> or %x{echo off; start #{login_curl}; exit}
>
> I no longer have access to a Windows machine so I cannot test it myself.
>
> HIH
>
> ct.
>
>
>
> On Thu, Sep 18, 2014 at 10:45 PM, Harsh Trivedi 
> <harshjtrivedi94@gmail.com <mailto:harshjtrivedi94@gmail.com>> wrote:
>
>     Hello,
>
>     I have been making an app in Shoes, in which I need to run a
>     system command:
>     eg. say my system command is
>     login_curl = 'curl ...'
>     I have tried it with many approaches like :
>       IO.popen("#{login_curl}").gets
>       system("#{login_curl}")
>       `#{login_curl}`
>       Open3.capture2("#{login_curl}")
>       Open3.capture2e("#{login_curl}")
>       Open3.capture3("#{login_curl}")
>
>     Each of the above approach works perfectly in linux,
>     and it works in windows also,
>     but my problem is that in Windows when i run the shoes app,
>     and whenever any of the above command is run,
>     a terminal window opens for a second and then closes itself.
>     (basically to run that 'login_curl' command on terminal)
>     I dont want my user to keep seeing a window terminal pop up
>     whenever system command is executed in shoes app on windows.
>
>     I am not at all used to windows and so need some help!
>
>     Thanx in advance :)
>
>

Re: [shoes] problem running system commands on windows from shoes app

From:
Harsh Trivedi
Date:
2014-09-20 @ 12:33
Hi,
First of all, thanks Carlos and Cecil for replying to my mail to quickly,
and am sorry, it took time for me to respond back.
I tried the possibility as suggested by Carlos:

%x{echo off; #{login_curl}; exit}
or %x{echo off; start #{login_curl}; exit}

It opens the windows console for few milisecond and closes it. It still
pops up the console though for few miliseconds (pretty much visibly). Also
the call is non-blocking, I guess, since when I do:

login_response = %x{echo off; start #{login_curl}; exit}
It doesn't respond to me the output of the system command, but the system
command it self. The actual command is executed after returning.
As you said, I was unaware about rubyw due to my complete inexperience on
windows platform. Using extension .rbw instead of .rb in a normal ruby
script, invariably stop the window popup from appearing, but not it a Shoes
application.
For convincing ruby to not open window popup, .rbw could be used but not in
case of Shoes. I wish if it were possible. If it is then please do let me
know.


@cecil,
As you said, I would definately open an issue soon on this problem in
shoes3.2 and thanks for your guidance.
I know about the fact that I can write any ruby code in shoes I want, and
it just runs. But the curl request that I want to make, doesn't fit into
any ruby library. I want to make https login request to an insecure server
(one whose certificate is not verified).
These are the possibilities I have experimented through:
 Net:Http
Rest-client
Faraday
Http-party
Typhoeus
Curb
 Some of the above dont support insecure request (One equivalent to
--insecure or -k flag in cURL), while some have this option but for some
reasons doesn't work out in my scenario (Typhoeus is the closest to my
requirement, but that still doesn't work in my case ). Also I am unable get
Shoes getting the 'typhoeus' gem required in windows, it gives some error.
Its only the cURL request from windows/linux terminal that works perfectly,
so I was so keen to solving this issue.
 BTW, I tried changing my shoes file's extension from .rb to .rbw expecting
it to use rubyw in windows, but it didn't work. If there is anything else I
can do to solve this issure, do let me know.


Thanks a Lot,
Harsh

On Sat, Sep 20, 2014 at 10:08 AM, Cecil Coupe <ccoupe@cableone.net> wrote:

>  Rubyw is a clue to what's needed but that doesn't help existing Shoes.
> It seems like a good idea for Shoes/Windows.  Please file a bug report for
> Shoes 3.2 so the idea doesn't get lost.  Too soon to say how hard it will
> be to fix it.
>
> As a workaround and if curl is what you need to run you can there are many
> things you can do with Ruby's http code that isn't in the Shoes download
> implementation.  Shoes 3.2 is a pretty complete Ruby so there is a lot
> there in the stdlib's. Documentation is pretty sparse for the http options,
> but it might do what you need curl for, assuming Shoes download doesn't
> work for you.
>
> --Cecil
>
> On 09/19/2014 10:17 AM, Carlos R. Tirado wrote:
>
>    Have you tried running your script on Windows not with ruby, but rubyw
> ?
>
>  Another possibility for suppressing the terminal window could be
> something like:
>
> %x{echo off; #{login_curl}; exit}
> or %x{echo off; start #{login_curl}; exit}
>
>  I no longer have access to a Windows machine so I cannot test it myself.
>
>  HIH
>
>  ct.
>
>
>
> On Thu, Sep 18, 2014 at 10:45 PM, Harsh Trivedi <harshjtrivedi94@gmail.com
> > wrote:
>
>>  Hello,
>>
>>  I have been making an app in Shoes, in which I need to run a system
>> command:
>> eg. say my system command is
>> login_curl = 'curl ...'
>> I have tried it with many approaches like :
>>      IO.popen("#{login_curl}").gets
>>     system("#{login_curl}")
>>     `#{login_curl}`
>>     Open3.capture2("#{login_curl}")
>>      Open3.capture2e("#{login_curl}")
>>     Open3.capture3("#{login_curl}")
>>
>>  Each of the above approach works perfectly in linux,
>> and it works in windows also,
>> but my problem is that in Windows when i run the shoes app,
>> and whenever any of the above command is run,
>> a terminal window opens for a second and then closes itself.
>> (basically to run that 'login_curl' command on terminal)
>> I dont want my user to keep seeing a window terminal pop up
>> whenever system command is executed in shoes app on windows.
>>
>>  I am not at all used to windows and so need some help!
>>
>>  Thanx in advance :)
>>
>>
>
>

Re: [shoes] problem running system commands on windows from shoes app

From:
Cecil Coupe
Date:
2014-09-20 @ 20:27
On 09/20/2014 06:33 AM, Harsh Trivedi wrote:
> Some of the above dont support insecure request (One equivalent to 
> --insecure or -k flag in cURL), while some have this option but for 
> som e reasons doesn't work out in my scenario (Typhoeus is the closest 
> to my requirement, but that still doesn't work in my case ). Also I am 
> unable get Shoes getting the 'typhoeus' gem required in windows, it 
> gives some error.
>
I'm not surprised that failed in windows. Typhoeus claims to wrap 
libcurl - the error might be that libcurl.dll (and others that go with 
curl) are not part of the Shoes sandbox (where all the external dlls 
that Shoes uses are kept. You could try copying (not moving, copying) 
the dlls from where curl has them to where Shoes want's them. Error 
messages will be critical to figure out which dll is missing if you go 
that route. Search to find 'libshoes.dll' on the Windows box - that 
directory is where

You could also install Ruby on the Windows box (see RubyInstaller - pick 
the 32 bit one even if you're on Win 64 and then install the appropriate 
devkit ) and then install the gem on windows. Then you can tell shoes 
where that gem is. You might have to install and build curl on Windows 
from source to find the .h files for devkit and Ruby. That would be a 
major pain in the behind.

There's probably a few more tricks available for the very determined but 
I'm not Windows knowledgeable enough to say more.



Re: [shoes] problem running system commands on windows from shoes app

From:
Cecil Coupe
Date:
2014-09-19 @ 07:38
There is a way to run a windows cmd w/o the console popping up. How to
convince Ruby to do that should be found on one of the ruby forums.
On Sep 18, 2014 11:45 PM, "Harsh Trivedi" <harshjtrivedi94@gmail.com> wrote:

> Hello,
>
> I have been making an app in Shoes, in which I need to run a system
> command:
> eg. say my system command is
> login_curl = 'curl ...'
> I have tried it with many approaches like :
>     IO.popen("#{login_curl}").gets
>     system("#{login_curl}")
>     `#{login_curl}`
>     Open3.capture2("#{login_curl}")
>     Open3.capture2e("#{login_curl}")
>     Open3.capture3("#{login_curl}")
>
> Each of the above approach works perfectly in linux,
> and it works in windows also,
> but my problem is that in Windows when i run the shoes app,
> and whenever any of the above command is run,
> a terminal window opens for a second and then closes itself.
> (basically to run that 'login_curl' command on terminal)
> I dont want my user to keep seeing a window terminal pop up
> whenever system command is executed in shoes app on windows.
>
> I am not at all used to windows and so need some help!
>
> Thanx in advance :)
>
>