[asterisk-users] running a asterisk -rx command in bash backgroun

Gordon Henderson gordon+asterisk at drogon.net
Sun Sep 6 08:09:49 CDT 2009


On Sun, 6 Sep 2009, Elliot Murdock wrote:

> Hello Gordon!
>
> Thanks...it works now.
>
> How did you notice that it needed input from the keyboard?

Experience. (Of being a unix/linux user/sysadmin for 25+ years)

I ran:

   dsx# rasterisk -x 'sip show peers' > /tmp/foo &
   [1] 8172
   dsx#

Then hit 'enter' again to get it's termination message, but I got:

   [1]+  Stopped                 rasterisk -x 'sip show peers' >/tmp/foo

experience tells me that when a job does that, it's waiting on keyboard 
input. I then typed:

   dsx# fg

and it completed with what I expected in the first place:

   rasterisk -x 'sip show peers' >/tmp/foo

> Do you think I should make the developers aware of this issue?

I suspect it's a side-effect of the keyboard/screen initialisation, but 
I've not looked at the code. ...

Hm. I just have (looked at the code) - maybe possible to not initialise 
the terminal stuff if -x is passed, but who knows... At least you have a 
solution now!

Gordon



>
> Thanks,
> Elliot
>
> On Sun, Sep 6, 2009 at 2:12 PM, Gordon
> Henderson<gordon+asterisk at drogon.net> wrote:
>> On Sun, 6 Sep 2009, Elliot Murdock wrote:
>>
>>> Hello!
>>>
>>> I have a very simple bash script:
>>>
>>> #!/bin/bash
>>> asterisk -rx "sip show peers" > /var/log/devices
>>>
>>> When I run it in bash shell, everything works fine, but if I
>>> background it (by adding & or using bg), nothing appears in the
>>> /var/log/devices file.
>>>
>>> Any reason for this behavior or help would be great!
>>
>> Even though it doesn't need it, it seems to be expecting keyboard input,
>> so it stalls. Odd, but I'm sure there's a reason for it.
>>
>> Try this:
>>
>>   rasterisk -x 'sip show peers' > /var/log/devices < /dev/null &
>>
>> You may now have lots of processes stuck, waiting, so best run
>>
>>   ps ax | fgrep asterisk
>>
>> to check.
>>
>> Gordon
>>
>> _______________________________________________
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>
>> AstriCon 2009 - October 13 - 15 Phoenix, Arizona
>> Register Now: http://www.astricon.net
>>
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>   http://lists.digium.com/mailman/listinfo/asterisk-users
>>
>
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> AstriCon 2009 - October 13 - 15 Phoenix, Arizona
> Register Now: http://www.astricon.net
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>


More information about the asterisk-users mailing list