Skip navigation
3455 Views 5 Replies Latest reply: Dec 27, 2006 9:32 AM by Deepak Bhat RSS
Calculating status... 18 posts since
Feb 17, 2006
Currently Being Moderated

Mar 30, 2006 8:14 AM

Reload plugin

How would I reload the plugin using a bash shell script? 

 

Thanks!

  • Matt Tucker Jiver 3,190 posts since
    Jun 28, 2001
    Currently Being Moderated
    Mar 30, 2006 4:51 PM (in response to Justin Selleck)
    Re: Reload plugin

    jselleck,

     

    I can''t think of an easy way to do so. Can you explain the use-case so we can understand what you''re trying to do better?

     

    Regards,

    Matt

  • LG KeyContributor 6,132 posts since
    Dec 13, 2005
    Currently Being Moderated
    Mar 31, 2006 11:56 AM (in response to Justin Selleck)
    Re: Reload plugin

    Hi jselleck,

     

    do you want to do the same thing as one could do using the web admin interface?

    You could use curl or wget to do this. I recently wrote a perl script to broadcast a message form the command line using the broadcast plugin.

     

    LG

    • Bronze 5 posts since
      Apr 25, 2006
      Currently Being Moderated
      Dec 23, 2006 1:20 AM (in response to LG)
      Re: Reload plugin

      Hey,

       

      I tried using curl but it fails becoz the auth page requiers javascript to be enabled.

       

      Can you plz explain how you achieved this becoz even I am trying to do the same thing using curl or lynx. I need to reload the asterisk-im pluigin.

       

      Or could you give me your perl script ?

       

      Thanks,

      Deepak

      • LG KeyContributor 6,132 posts since
        Dec 13, 2005
        Currently Being Moderated
        Dec 26, 2006 4:25 AM (in response to Deepak Bhat)
        Re: Reload plugin

        Hi,

         

        you don''t need to retrieve the login.jsp page, sending username+pass and then retrieving the cookie is fine.

         

         

        I did post this script somewhere in this forum already ... using the code tag it may have some problems with & so  you may need to fix some lines where & is used.

         

        LG

         

         

        
        #!perl.exe
        #my $version = ''v0.01'';
        use strict;
        use warnings;
        use utf8;
        use IO::Socket;
        use IO::Handle;
        
        $|=1;
        my $message = (defined($ARGV[0]))?"@ARGV":"";
        
        my ($buf, $buflen, $buf2);
        
        # adjust this
        my $my_servername = "127.0.0.1";
        my $my_adminport = "9090";
        my $my_adminpath = ""; # ''Wifi/'' if you are using Tomcat and ''Wifi.war'', don''t forget the trailing ''/''
        my $my_adminuser = "admin";
        my $my_password = "test";
        my $baseurl = "http://" . $my_servername . ":" . $my_adminport . "/" . $my_adminpath;
        
        my $loginpage = "login.jsp";
        my $broadcastpage = "user-message.jsp";
        my $TRGT_PROTO = ''tcp'';
        my $HTTP_HEADER = "Host: " . $my_servername . ":" . $my_adminport . "\r\n" .
        "Content-Type: application/x-www-form-urlencoded\r\n" .
        "Connection: close\r\n" .
        "Content-Type: text/html; charset=UTF-8\r\n\r\n";
        my $cookie = "";
        
        # login - POST and GET are possible, we will use POST
        #printf("############# login #############\n");
        $buf = "url=/" . $my_adminpath . $broadcastpage . "&";
        $buf .= "login=true" . "&";
        $buf .= "username=" . $my_adminuser . "&";
        $buf .= "password=" . $my_password;
        $buflen=length($buf);
        $buf = "POST " . $baseurl . $loginpage . " HTTP/1.0\r\n" .
        "Content-Length: " . $buflen . "\r\n" .
        $HTTP_HEADER .
        $buf;
        &send();
        &get_cookie();
        
        #printf("############# sending broadcast #############\n");
        $message =~ s/\%/\%25/g;
        $message =~ s/\+/\%2b/g;
        $message =~ s/\&/\%26/g;
        
        $buf = "tabs=true" . "&";
        $buf .= "send=true" . "&";
        $buf .= "message=" . $message;
        $buflen=length($buf);
        $buf = "POST " . $baseurl . $broadcastpage . " HTTP/1.0\r\n" .
        "Content-Length: " . $buflen . "\r\n" .
        $cookie . "\r\n" .
        $HTTP_HEADER .
        $buf;
        &send();
        
        #printf("############# success ? #############\n");
        if ($buf2 =~ /$broadcastpage\?success=true/)
        {
        printf("OK\n");
        } else
        {
        printf("Error\n");
        exit(3);
        };
        exit(0);
        
        sub get_cookie()
        {
        if ($buf2 =~ /(Cookie\s*:\s[^;]*)/)
        {
        $cookie = $1;
        } else
        {
        printf("Could not get Cookie / Login");
        exit(1);
        };
        #printf("############# Cookie: %s\n", $cookie);
        };
        sub send()
        {
        #printf("############# Send: %s\n", $buf);
        my $sock = new IO::Socket::INET->new(PeerAddr => $my_servername,
        PeerPort => $my_adminport, Proto => $TRGT_PROTO);
        if (!defined $sock)
        {
        printf("Could not create socket.\n");
        exit(2);
        };
        $sock->send($buf);
        $buf = "";
        $buf2 = "";
        while (<$sock>)
        {
        read($sock, $buf, 1000);
        $buf2 .= $buf;
        };
        close ($sock);
        #printf("############# Recv: %s\n", $buf2);
        };
        

         

More Like This

  • Retrieving data ...

Bookmarked By (0)