LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 October 20 2018

duke-of-bytes
Member

IP PBX Auto reboot

Hello there
I have an ip pbx that is hanging from time to time and the only solution is to reboot it.
I am not looking to replace it now but im looking to reboot it manually.
The way to reboot is to log on to the webpage.. Put user and pass.. Then click on reboot.. Then another reboot link.

Is it possible to set a script to do this lets say every 3 or 4 hours?

Offline

#2 October 20 2018

rolf
Member

Re: IP PBX Auto reboot

of course I wouldnt know how though.
I did this like more than 10 years ago using IE and WSH.
Check out autoit.
Some browser extensions can probably do this.
Or a testing framework such as selenium or something with Phantom.js
Maybe just curl and sleep (pun intended) if it's a matter of sending a few POSTs in a row.
Google it!

Offline

#3 October 20 2018

duke-of-bytes
Member

Re: IP PBX Auto reboot

I know nothing about programming or scripting.. Guess ill have to do it manually or let an intern do it hehe

Offline

#4 October 22 2018

duke-of-bytes
Member

Re: IP PBX Auto reboot

rolf wrote:

of course I wouldnt know how though.
I did this like more than 10 years ago using IE and WSH.
Check out autoit.
Some browser extensions can probably do this.
Or a testing framework such as selenium or something with Phantom.js
Maybe just curl and sleep (pun intended) if it's a matter of sending a few POSTs in a row.
Google it!

so i found this on microsoft pages , but i was wondering if i can modify to click on a link instead of an exe ..

<#
Created:  January 18, 2014
Version:  2.0
Description:  On login, launch Internet Explorer to a specified URL, and then open an executable file.
Notes:  If the workstation is running Windows 7, login as the user, open "GPEDIT.MSC", and navigate to the following location.

User Configuration\Windows Settings\Scripts (Logon/Logoff)

Next, open "Logon" and go to the "PowerShell Scripts" tab.  Then, add this script to it.  However, first modify 
the following variables.  You can edit it in a text editor or in the PowerShell ISE.

$Url
$Username
$Password
$Executable

IMPORTANT:  Before running the script, open the web browser and go to the web site that will be specified in this 
script and right click in the username field and select Inspect Element.  Locate the "Input Name" and then copy and 
paste it in place of "UsernameElement" located at the end of this script (line 61).  Then, inspect the password field, 
and copy and paste the "Input Name" in place of "PasswordElement" located at the end of this script (line 62).  Then, 
right click on the submit button on the URL and locate the Input Name and then copy paste it in place of "SubmitElement"
at the end of this script (line 63).

#>

# Edit this to be the URL or IP address of the site to launch on login

$Url = “http://192.168.120.251:8080/cgi-bin/webctrl.cgi”

# Edit this to be the username

$Username=”admin”

# Edit this to the corresponding password

$Password=”SecServer777”

# Edit this to be the path to the executable.  Include the executable file name as well.

$Executable = "c:\windows\system32\notepad.exe"

# Invoke Internet Explorer

$IE = New-Object -com internetexplorer.application;
$IE.visible = $true;
$IE.navigate($url);

# Wait a few seconds and then launch the executable.

while ($IE.Busy -eq $true)

{

Start-Sleep -Milliseconds 2000;

}

# The following UsernameElement, PasswordElement, and LoginElement need to be modified first.  See the notes at the top
# of the script for more details.

$IE.Document.getElementById(“UsernameElement”).value = $Username
$IE.Document.getElementByID(“PasswordElement”).value=$Password
$IE.Document.getElementById(“SubmitElement”).Click()

while ($IE.Busy -eq $true)

{

Start-Sleep -Milliseconds 2000;

}

Invoke-Item $Executable

also i tried an extension ( imacros ) .. it records correctly and the user/pass are shown ..but i dont know why it is not logging in the page

Offline

#5 October 22 2018

rolf
Member

Re: IP PBX Auto reboot

I think I found a way for you which is worth a try:

Get Firefox and install the DejaClick plugin:

http://dejaclick.alertsite.com/

Now you can use this to record and replay your clicks.

This is half of the work, the other half would be to launch this periodically. Unfortunately, DejaClick doesn't seem to do this.
But we can find tricks. For example:

From the DejaClick FAQ wrote:

Is there a way to run my script when Firefox starts up?

Yes. The easiest way is to create a DéjàClick Super Bookmark by clicking on the toolbar. Make that your startup homepage: in the Firefox Options dialog, in the Startup section of the Main tab, click the Use Bookmark button and select the DéjàClick Super bookmark you just created as your Home Page URL. Then, change the When Firefox starts option to Show my home page.

Another option is to create a shortcut to execute Firefox and pass your DéjàClick URL via the command line.

So now you can launch your script from the command line, all you have left to do is use the Windows Task Scheduler to launch it every few hours.

This or find a plugin which can launch links or bookmarks periodically.

Or find another plugin which can record links AND launch them periodically to replace DejaClick.

I haven't tried any of this but I thin it's worth a try.

In any case it's an example of how you possibly assemble a solution from various parts.

Offline

#6 October 22 2018

duke-of-bytes
Member

Re: IP PBX Auto reboot

so dejaclick worked on firefox and on chrome .. i was able to record and play the script .. but once i try to add a super bookmark i get an error

Exception encountered in DejaCommand.bookmarkCommand()
Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsITransactionManager.doTransaction] (NS_ERROR_UNEXPECTED) (2114)

i reinstalled firefox , cleared my cache .. but still same error
the script is saved in .xml  so i have no clue how to run it without the dejaclick

Offline

#7 October 22 2018

rolf
Member

Re: IP PBX Auto reboot

Nice. Maybe you can try it in Chrome.

If you can create a bookmark in Chrome, then maybe you can extract a specific URL from the bookmark (Bookmarks->bookmark->Edit) and then launch this URL from the command line (I can give you instructions on how to, there is a special --disable-web-security switch).

It's just an idea anyway, if this does not work, then maybe something can be pieced together using other building blocks. There are many automation software out there.

I hope you don't mind, I am just giving you ideas of things that I would be trying myself if I had the same problem.

You can also go down the route of coding something, which is pretty much guaranteed to work, but it would be better to first try piecing something together using extensions, etc. if it's possible, even if you are a developer because coding usually brings more concerns and complexities, such as installing the environment, learning the API, debugging.

Last edited by rolf (October 22 2018)

Offline

#8 October 22 2018

duke-of-bytes
Member

Re: IP PBX Auto reboot

rolf wrote:

Nice. Maybe you can try it in Chrome.

If you can create a bookmark in Chrome, then maybe you can extract a specific URL from the bookmark (Bookmarks->bookmark->Edit) and then launch this URL from the command line (I can give you instructions on how to, there is a special --disable-web-security switch).

It's just an idea anyway, if this does not work, then maybe something can be pieced together using other building blocks. There are many automation software out there.

I hope you don't mind, I am just giving you ideas of things that I would be trying myself if I had the same problem.

You can also go down the route of coding something, which is pretty much guaranteed to work, but it would be better to first try piecing something together using extensions, etc. if it's possible, even if you are a developer because coding usually brings more concerns and complexities, such as installing the environment, learning the API, debugging.

your help is highly appreciated Rolf
bookmarking in dejaclick is only valid for firefox .. but for some weird reason it now working
manual replay is working for chrome and firefox
i am not sure bookmarking works for an extension

Offline

#9 October 22 2018

rolf
Member

Re: IP PBX Auto reboot

If manual replay works for Firefox, then you can set the bookmark for the replay as default page for Firefox, so as soon as you open firefox, it will launch this. If Firefox is your main browser then I think you can create an alternate profile for that. Then you can trigger the procedure from the command-line just by launching Firefox (optionally with the alternate profile). As soon as you can launch the procedure from the command line then it's easy to automate it using Windows Task Scheduler or some other solution.

Offline

#10 October 22 2018

duke-of-bytes
Member

Re: IP PBX Auto reboot

ok the main question : how to bookmark the replay ? did you see how dejaclick works ? there is no website

Offline

#11 October 22 2018

rolf
Member

Re: IP PBX Auto reboot

duke-of-bytes wrote:

ok the main question : how to bookmark the replay ? did you see how dejaclick works ? there is no website

It's in my post after the one where you pasted the error.

Here is the site:
http://dejaclick.alertsite.com/

There is also a FAQ with a section about bookmarks:

https://support.smartbear.com/alertsite … marks.html

This post would also help (same problem as you) to launch the script from command line.

https://ubuntuforums.org/archive/index. … 80728.html

I cannot install this addon on Firefox (incompatible version) I tried the one on Chrome but there is no Bookmark feature, so I can't test it.

Last edited by rolf (October 22 2018)

Offline

#12 October 23 2018

duke-of-bytes
Member

Re: IP PBX Auto reboot

rolf wrote:
duke-of-bytes wrote:

ok the main question : how to bookmark the replay ? did you see how dejaclick works ? there is no website

It's in my post after the one where you pasted the error.

Here is the site:
http://dejaclick.alertsite.com/

There is also a FAQ with a section about bookmarks:

https://support.smartbear.com/alertsite … marks.html

This post would also help (same problem as you) to launch the script from command line.

https://ubuntuforums.org/archive/index. … 80728.html

I cannot install this addon on Firefox (incompatible version) I tried the one on Chrome but there is no Bookmark feature, so I can't test it.

still the main and first thing to do : the bookmarking ..does not work
when i bookmark i get an error that i mentioned earlier

Offline

Board footer