<div dir="ltr"><div><div>I'm parsing ` sudo asterisk -rx "core show calls" | grep active | head -c 1 ` as an external call from within the Asterisk dialplan then passing it to agi, but this seems really hacky and ugly.</div><div><br></div><div>However, I cannot find any ARI/AGI/AMI function (or global variable I can get with agi) which shows me this.</div><div><br></div><div>Any ideas?!?</div></div><div><br></div><div>In case it helps and you're wondering why...</div>I need to ensure that a MusicOnHold stream is only running when there's a caller on hold and listening.<div>To do that, I need to rewrite and reload the moh.conf file when the caller hangs up IF there are no other callers (ie 

there's just 1 active call as the caller hangs up), and then 

rewrite and reload again when there's a new caller.</div><div><br></div><div><br></div></div>