Henry Junior
2005-Aug-29 15:39 UTC
[Asterisk-Users] echo system command and set the results to a new variable
I am looking to issue a 'System cmd' that will echo the results into a new variable -- can anyone tell me the correct way to do this? example: at the terminal I am currently able to issue this command: echo | date > date.txt I end up with a file called date.txt with the contents: Mon Aug 29 18:32:45 EDT 2005 I would like to issue a command in my dialplan that puts the date into a new variable something like this: System(echo | date > Set(newVariableName=theDateEchoReturns) So that the newVariableName=Mon Aug 29 18:32:45 EDT 2005 The objective in this case is to format the date according to the Unix Time format listed above. I am certainly open to other options for doing this. The default ${TIMESTAMP} format doesn't work for my needs. Thanks!
Tzafrir Cohen
2005-Aug-29 17:59 UTC
[Asterisk-Users] echo system command and set the results to a new variable
On Mon, Aug 29, 2005 at 06:39:47PM -0400, Henry Junior wrote:> I am looking to issue a 'System cmd' that will echo the results into > a new variable -- can anyone tell me the correct way to do this? > > example: at the terminal I am currently able to issue this command: > echo | date > date.txtDo you want to run that command in the shell? This pipes the output of 'echo' (with no parameters: just prints a single newline) to date (with no params, ignores its input anyway) and redirects the output of date into date.txt .> I end up with a file called date.txt with the contents: Mon Aug 29 > 18:32:45 EDT 2005As expected.> > I would like to issue a command in my dialplan that puts the date > into a new variable something like this: > System(echo | date > Set(newVariableName=theDateEchoReturns)System doesn't do that . chan_backticks does: http://pbxfreeware.com/app_backticks.c But then again, I figure that there's a simpler way.> > So that the newVariableName=Mon Aug 29 18:32:45 EDT 2005 > > The objective in this case is to format the date according to the > Unix Time format listed above. I am certainly open to other options > for doing this. The default ${TIMESTAMP} format doesn't work for my > needs.What do you need it for? -- Tzafrir Cohen | tzafrir@jbr.cohens.org.il | VIM is http://tzafrir.org.il | | a Mutt's tzafrir@cohens.org.il | | best ICQ# 16849755 | | friend
Henry Junior
2005-Aug-29 20:33 UTC
[Asterisk-Users] Re: echo system command and set the results to a new variable
>> I am looking to issue a 'System cmd' that will echo the results into >> a new variable -- can anyone tell me the correct way to do this? >> >> example: at the terminal I am currently able to issue this command: >> echo | date > date.txt >> > > Do you want to run that command in the shell? This pipes the output of > 'echo' (with no parameters: just prints a single newline) to date > (with > no params, ignores its input anywaySorry if this wasn't written clearly before. I want to issue a System cmd in my dialpan that is similar to the unix echo command stated above. *EXCEPT* that I want to pipe the results into a *new* variable (vs a text file.) Ideally, what would happen is in my diaplan I would issue the 'echo | date' command and pipe the output to a newly created variable with the appropriate output. example: NewVariable=Mon Aug 29 18:32:45 EDT 2005 Do you know how I can do this? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050829/2993ea80/attachment.htm
Henry Junior
2005-Aug-29 20:35 UTC
[Asterisk-Users] Re: echo system command and set the results to a new variable
As far as I know ${EPOCH} would not work because I need the results to be similar to this format: Mon Aug 29 18:32:45 EDT 2005> What about variable ${EPOCH} ?-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050829/9f6c74be/attachment.htm
Michel Koenen
2005-Aug-30 03:15 UTC
[Asterisk-Users] Re: echo system command and set the results to a new variable
> > From: Henry Junior <henryjunior@gmail.com> > > I want to issue a System cmd in my dialpan that is similar to the > unix echo command stated above. *EXCEPT* that I want to pipe the > results into a *new* variable (vs a text file.) > > Ideally, what would happen is in my diaplan I would issue the 'echo | > date' command and pipe the output to a newly created variable with > the appropriate output. > > example: > NewVariable=Mon Aug 29 18:32:45 EDT 2005 > > Do you know how I can do this?Assuming that you want to execute some Unix commands and feedback the output as variables to the dialplan in Asterisk this is possible with an AGI bash script. Use the 'set variable' command http://www.voip-info.org/tiki-index.php?page=set+variable You can use the example at http://yakko.cs.wmich.edu/~drclaw/asterisk/cidname/ , reuse the framework to read the standard AGI variables and rewrite it to your own code. Regards, Michel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050830/8e450162/attachment.htm