Scripting MGR Actions

tempmj
Member
Posts: 20
Joined: 14 Mar 2007 08:55
Location: VA, USA
Contact:

Scripting MGR Actions

Post by tempmj »

I am trying to script some actions in MGR to automatically run at a predefined time. For an example, i am trying to forward my extension to my cell phone at 8AM and unforward it at 5PM.
I issued the command
[INDENT]mgr -log fwdToCell[/INDENT]
then i went into the dynamic state user and forwarded my extension to my cell phone.
I now have a file that contains:
[INDENT]SET Dynamic_State_Subscriber "1": "6231": "1"
{
Forward = "RV_IMD",
Number_Forward = "9(cell number omitted)",
Secondary_Line_Forward = "RV_IMD",
Secondary_Line_Number_Forward = "9(cell number omitted)"
}[/INDENT]

I did a similar thing to create an unforward file
[INDENT]SET Dynamic_State_Subscriber "1": "6231": "1"
{
Forward = "NO_RV",
Number_Forward = "6231",
Secondary_Line_Forward = "NO_RV",
Secondary_Line_Number_Forward = "6231"
}[/INDENT]

Now i'm trying to run it with a cron job.

I added the following lines to the MTCL user's crontab:
[INDENT]0 8 * * * /DHS3bin/oneshot/mtcl/mgr -nodico -XX fwdToCell > /DHS3bin/mtcl/cronlog.txt 2>&1
0 17 * * * /DHS3bin/oneshot/mtcl/mgr -nodico -XX unfwdFromCell > /DHS3bin/mtcl/cronlog.txt 2>&1[/INDENT]
including the section to redirect the output to cronlog.txt so i can tell if it ran and/or had any issues

it never seems to run. The dynamic state never changes, and the cronlog.txt does not get updated

I've seen this on other systems where the program i'm trying to run has to initialize the system's database link (which it does upon login), and i'm assuming it's something similar for MGR to access the PCX database. Can anyone shed some light on this?
User avatar
tot3nkopf
Alcatel Unleashed Certified Guru
Alcatel Unleashed Certified Guru
Posts: 4058
Joined: 02 Feb 2006 10:41
Location: Germany & Romania
Contact:

Post by tot3nkopf »

For me it works just the way you did it, with output to log file, too.
tempmj
Member
Posts: 20
Joined: 14 Mar 2007 08:55
Location: VA, USA
Contact:

Seems to actually work

Post by tempmj »

I believe it was my impatience that was keeping it from working.

After closely looking at /var/log/syslog and watching it while updating the cron jobs and watching them run, i figured out why it appeared to not work for me. Rather than waiting until the times that i needed it (8am and 5pm) i set it to a time one minute out. So if it's 9:16am, i edited the cron job to run at 9:17am. Looking at the syslog file, i found that it only actually reloads the cron jobs to refresh the job list once a minute, so it refreshed my request, but since by the time it was refreshed, the job had already been scheduled, it didn't work.

I tested this by setting the job to two minutes out, and it worked flawlessly.

Now to set it to the actual job run times of 8 and 5.

Thanks for the info that this way actually works. I would have still been hunting for special stuff i needed to do to make it work, rather than looking at the real problem of my test schedule.
User avatar
letacla
Member
Posts: 33
Joined: 28 Dec 2009 04:38
Location: Romania

Post by letacla »

tempmj wrote:I am trying to script some actions in MGR to automatically run at a predefined time. For an example, i am trying to forward my extension to my cell phone at 8AM and unforward it at 5PM.
I issued the command
[INDENT]mgr -log fwdToCell[/INDENT]
then i went into the dynamic state user and forwarded my extension to my cell phone.
I now have a file that contains:
[INDENT]SET Dynamic_State_Subscriber "1": "6231": "1"
{
Forward = "RV_IMD",
Number_Forward = "9(cell number omitted)",
Secondary_Line_Forward = "RV_IMD",
Secondary_Line_Number_Forward = "9(cell number omitted)"
}[/INDENT]

I did a similar thing to create an unforward file
[INDENT]SET Dynamic_State_Subscriber "1": "6231": "1"
{
Forward = "NO_RV",
Number_Forward = "6231",
Secondary_Line_Forward = "NO_RV",
Secondary_Line_Number_Forward = "6231"
}[/INDENT]

Now i'm trying to run it with a cron job.

I added the following lines to the MTCL user's crontab:
[INDENT]0 8 * * * /DHS3bin/oneshot/mtcl/mgr -nodico -XX fwdToCell > /DHS3bin/mtcl/cronlog.txt 2>&1
0 17 * * * /DHS3bin/oneshot/mtcl/mgr -nodico -XX unfwdFromCell > /DHS3bin/mtcl/cronlog.txt 2>&1[/INDENT]
including the section to redirect the output to cronlog.txt so i can tell if it ran and/or had any issues

it never seems to run. The dynamic state never changes, and the cronlog.txt does not get updated

I've seen this on other systems where the program i'm trying to run has to initialize the system's database link (which it does upon login), and i'm assuming it's something similar for MGR to access the PCX database. Can anyone shed some light on this?

hi

i try to execute that sript but i receive an error:
(101)xma0000> /DHS3bin/oneshot/mtcl/mgr -nodico -XX fwdToCell

ooo Starting at <10/09/10 00:26> ...
ooo Compiling Command file "fwdToCell" ...
error: line 1: parse error
error: Compilation: fatal error

ooo Aborted. at <10/09/10 00:26> ...


and script is:
SET Dynamic_State_Subscriber "1":"2009":"1"
{
Forward = "RV_IMD",
Forward_Directory_Number = "007xxxxxxxx",
Secondary_Line_Forward = "RV_IMD",
Secondary_Line_Number_Forward = "007xxxxxxxxx"
}

0 is ars pfx and 07xxxxxxxx mobile nr.

can you help'me?

thx
mbaledent
Member
Posts: 85
Joined: 23 Feb 2009 08:52

Post by mbaledent »

Hi,

Do not forget to put a carriage return at the end of your mgr script.

Regards.
tempmj
Member
Posts: 20
Joined: 14 Mar 2007 08:55
Location: VA, USA
Contact:

Post by tempmj »

I don't know if it's possible that the syntax may be different for your version.... to get a file you can just "run" by doing the mgr actions, do this:
mgr -log fwdToCell
then you are in mgr, do the action you want to take
exit mgr
it has created a file called fwdToCell
Just open the file and remove the line that looks like:
---------- Log file started <15/09/10 09:28> ----------
and save it. You are now good to go. This will capture exactly what your system is doing when you run mgr.
krzysioD
Alcatel Unleashed Certified Guru
Alcatel Unleashed Certified Guru
Posts: 1165
Joined: 30 Aug 2006 13:43
Location: Europe, Poland

Post by krzysioD »

Not very good way to do it.
But why not use an Entity Call with calendar ?
tempmj
Member
Posts: 20
Joined: 14 Mar 2007 08:55
Location: VA, USA
Contact:

Post by tempmj »

if you have multiple extensions in one entity. for example, i have my phone forwarded from 8-5 mon-fri to my cell, my boss has his forwarded to his cell 8-5 on friday, and we have three seperate on call numbers that with this scripting gets forwarded to the appropriate person on call's cell phone. Level 1 support has 4 people in rotation, level 2 has 13 people in rotation, and level 3 has 6 people in rotation. Each of the three groups have a virtual set that gets forwarded at 8am monday mornings to the appropriate on call technician (as defined by an external database). I don't know how an entity call will handle such a complex setup, but my external script puts the required MGR script on the pcx and runs it at the times that it is needed to have a change. This keeps the on call technicians from having to remember to do it when the go on call or come off of call.
krzysioD
Alcatel Unleashed Certified Guru
Alcatel Unleashed Certified Guru
Posts: 1165
Joined: 30 Aug 2006 13:43
Location: Europe, Poland

Post by krzysioD »

remote extension with different entity? :)
for such a complicated setup: use IVR, it would ask for free technician based on (for example) action like this client has worked with this technician.
Anyway: for level one i've always seen as many as 10 times more people than for level 3 or 4, but you say only 4 people? Strange.
tempmj
Member
Posts: 20
Joined: 14 Mar 2007 08:55
Location: VA, USA
Contact:

Post by tempmj »

ahh, but only one person is on call at a time (this is our internal help desk). It's a rotation of that many people, not that many people at a time. Only one person at a time is on call, so for the poor folks with 4 people on call, they are on call one week out of every 4 (once a month), the ones with 6 it's once every month and a half, and so forth. There's no way for the IVR to know the schedule of who is on call currently (especially if someone takes someone else's shift). I have a PHP/MySQL shift calendar that i use the database that drives it to create the MGR actions and then ftp them to the pcx and run mgr using these actions.
Post Reply

Return to “Linux tricks”