Running remote command via SSH causes Pharo to hang

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Running remote command via SSH causes Pharo to hang

Frank Church

I using the PipeableOSProcess to run ssh commands which return output and Pharo hangs when I try it. Commands executing locally work okay, but the ssh ones generally hang.

Transcript show: (PipeableOSProcess command: '~/deploy_scripts/linkproxy.sh -f 1591') output

eg The linkproxy.sh backgrounds an SSH command that enables both remote and local forwarding via the "command &" option. Is there some other option I can use to stop the script hanging?

The other part is when I use execute a command remotely via SSH. eg - ssh user@localhost 'execute remote command'. This option also results in a hang. Anyway I will make some further checks and report back.

Transcript show: (PipeableOSProcess command: '~/deploy_scripts/linkproxy.sh -f 1591') output

--
Frank Church

=======================
http://devblog.brahmancreations.com
Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Göran Krampe
On 12/28/2012 04:02 PM, Frank Church wrote:
>
> I using the PipeableOSProcess to run ssh commands which return output
> and Pharo hangs when I try it. Commands executing locally work okay, but
> the ssh ones generally hang.

I do this alot in my current project and I have a small little framework
around this because IIRC the "problem" is that your call to #output will
block until #atEnd. So what you want to do if you do not want to block
is to fork off a background process that reads without blocking. This
works really well for me, so I run multiple of these in parallell and
each is given its own background Process that reads and copies into a
WriteStream on a String. So if I ask my "wrapper" for the output it will
ask this stream for its contents instead.

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Frank Church


On 28 December 2012 23:44, Göran Krampe <[hidden email]> wrote:
On 12/28/2012 04:02 PM, Frank Church wrote:

I using the PipeableOSProcess to run ssh commands which return output
and Pharo hangs when I try it. Commands executing locally work okay, but
the ssh ones generally hang.

I do this alot in my current project and I have a small little framework around this because IIRC the "problem" is that your call to #output will block until #atEnd. So what you want to do if you do not want to block is to fork off a background process that reads without blocking. This works really well for me, so I run multiple of these in parallell and each is given its own background Process that reads and copies into a WriteStream on a String. So if I ask my "wrapper" for the output it will ask this stream for its contents instead.

regards, Göran


I jumped straight in and tried to hack without learning some Smalltalk basics but after spending a day with Pharo By Example I am beginning to make some progress.

Is the Transcript in Pharo 1.4 different from the one used in the PBE image? It displays ThreadedTranscript when I check its properties and it doesn't seem to hang like the PBE image.

Some example code would really help here.

Thanks




--
Frank Church

=======================
http://devblog.brahmancreations.com
Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Sean P. DeNigris
Administrator
In reply to this post by Frank Church
Frank Church wrote
I using the PipeableOSProcess... but the
ssh ones generally hang.
I don't know if this has anything to do with your problem, but I often run into hanging output with OSP and usually send... I think it's #setNonBlockingOutput... to the PipeableOSProcess before reading the output. Then IIRC #output should immediately return whatever's currently available, and you can keep looping to get more.

HTH,
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Ben Coman
In reply to this post by Frank Church
Frank Church wrote:

> On 28 December 2012 23:44, Göran Krampe <[hidden email]> wrote:
>
>  
>> On 12/28/2012 04:02 PM, Frank Church wrote:
>>
>>    
>>> I using the PipeableOSProcess to run ssh commands which return output
>>> and Pharo hangs when I try it. Commands executing locally work okay, but
>>> the ssh ones generally hang.
>>>
>>>      
>> I do this alot in my current project and I have a small little framework
>> around this because IIRC the "problem" is that your call to #output will
>> block until #atEnd. So what you want to do if you do not want to block is
>> to fork off a background process that reads without blocking. This works
>> really well for me, so I run multiple of these in parallell and each is
>> given its own background Process that reads and copies into a WriteStream
>> on a String. So if I ask my "wrapper" for the output it will ask this
>> stream for its contents instead.
>>
>> regards, Göran
>>
>>
>>    
> I jumped straight in and tried to hack without learning some Smalltalk
> basics but after spending a day with Pharo By Example I am beginning to
> make some progress.
>
> Is the Transcript in Pharo 1.4 different from the one used in the PBE
> image? It displays ThreadedTranscript when I check its properties and it
> doesn't seem to hang like the PBE image.
>
> Some example code would really help here.
>
> Thanks
>
>
>
>
>  
Transcript was replaced at some point - I "think" it was after PBE
publication.  I link to some related posts below.

Regarding sample code... what are you trying to do?  The way I commonly
use the Transcript is...
    Transcript crShow: something asString, '---', somethingElse asString.

asString might not be the most efficient way, but its simple.  Without
'asString', using the comma to concatenate strings often does does not
work since non-string classes generally don't understand comma.

http://code.google.com/p/pharo/issues/detail?id=3948
http://www.mail-archive.com/pharo-project@.../msg51417.html
http://code.google.com/p/pharo/issues/list?can=1&q=summary%3Atranscript&sort=-id&colspec=ID+Type+Status+Summary+Milestone+Difficulty&cells=tiles

Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Stéphane Ducasse
In reply to this post by Frank Church
> I jumped straight in and tried to hack without learning some Smalltalk basics but after spending a day with Pharo By Example I am beginning to make some progress.

:)

> Is the Transcript in Pharo 1.4 different from the one used in the PBE image? It displays ThreadedTranscript when I check its properties and it doesn't seem to hang like the PBE image.

From a client point of view this should be the same.
Now the one in 1.4 should be usable to show results of concurrent programs.

> Some example code would really help here.

What are you looking for?


>
> Thanks
>
>
>
>
> --
> Frank Church
>
> =======================
> http://devblog.brahmancreations.com


Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Frank Church


On 29 December 2012 12:56, Stéphane Ducasse <[hidden email]> wrote:
> I jumped straight in and tried to hack without learning some Smalltalk basics but after spending a day with Pharo By Example I am beginning to make some progress.

:)

> Is the Transcript in Pharo 1.4 different from the one used in the PBE image? It displays ThreadedTranscript when I check its properties and it doesn't seem to hang like the PBE image.

From a client point of view this should be the same.
Now the one in 1.4 should be usable to show results of concurrent programs.

> Some example code would really help here.

What are you looking for?



I was asking about a sample of the code Goran described in his answer (and that of Sean after his answer).

I need some code samples to help me learn better.




--
Frank Church

=======================
http://devblog.brahmancreations.com
Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Paul DeBruicker
On 12/29/2012 06:11 AM, Frank Church wrote:
>
>
> I was asking about a sample of the code Goran described in his answer
> (and that of Sean after his answer).
>
> I need some code samples to help me learn better.


You could probably do what they describe with a Future. See:

http://www.squeaksource.com/Futures.html and the blog post linked from
that page.

Reply | Threaded
Open this post in threaded view
|

Re: Running remote command via SSH causes Pharo to hang

Göran Krampe
In reply to this post by Frank Church
On 12/29/2012 03:11 PM, Frank Church wrote:
> I was asking about a sample of the code Goran described in his answer
> (and that of Sean after his answer).

I will see if I can get some for you later, pressed for time right now.

regards, Göran