Question

How can i connect Phonegap Android App to a remote system using Telnet and SSH and execute commands like shutdown ,etc.

Was it helpful?

Solution

Let me first say that this is merely a template to explain my thoughts. Remember that HTTPS would be a must to do this.

Setting up HTTPS on your webserver is the thing u need to do.

On the server

You can place a php file called cmd.php.

In that file you could do something like:

<?php

    if( get_the_argument_from_the_url_request ) {
        if (argument == "telnet") {
            // do your stuff
            exec("telnet ...");

        } else if( ... ) {
            // do your stuff
            exec("ssh ...");

        } else... // and so forth
    }

?>

On the phone

$.ajax({
    url: "http://www.yourwebsite.com/?telnet=some_command",
    success:function(data){
        // success code here
    }
});

If you want some sort of response form the server you can invoke a php script as a job when the server is rebooted.

You could create a database that the app itself and the server could write to, in order to create success/error messages.

There are ofc other solutions, but to put the idea on the table here it is.

I hope that i was of some sort of help. :)

OTHER TIPS

sockets-for-cordova

This Cordova plugin provides JavaScript API, that allows you to communicate with server through TCP protocol.

Currently we support these platforms: iOS, Android, WP8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top