Interacting with the linux system

Asked

Viewed 61 times

2

Is there any function or way to get javascript/Angularjs to communicate with linux?

For example:

<!doctype html>
<html ng-app="myApp">
    <head>
        <link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css">
    </head>
    <body>
        <h2>{{kapp}}</h2>
        <div class="busca" id="div1">
            <input class="form-control"type="text" placeholder="Digite o nome completo" ng-model="search"/>
            <button type="button" class="btn btn-lg btn-info" id="bot" ng-click="buscar(search)" onclick="fecha();">
                Search  
                <i class="glyphicon glyphicon-search"></i>
            </button>
        </div>
    </body>
    <script>
        angular.module('myApp', []);
        angular.module('myApp', []).controller("customersCtrl",function ($scope, $http)
        {   
            $scope.kapp = "Buscado";
            $scope.buscar = function (name)
            {
                $scope.search = name;
            }
    </script>
</html>

Well, there would be some way when 'name' gets a name and that name is passed to a variable from a Shellscript, python or C file ?

  • 1

    Not without a server-side language, for example php...

  • And using php, how would you do that?

  • A server-side language (Ruby or PHP, for example) + REST Services.

  • @Matheus using php I already answered as a reply.

  • Doing something similar to @Sneeps' reply.

1 answer

1


It works like @Matheus, you need a server-side language, so if that your javascript, Angularjs, html and Html5 is on the client-side ( and most likely to be ) don’t p/ make your server run any command, then in the case of php it would be like this:

<?php 
exec(' teste="ola mundo"'); 
exec('echo teste > arquivo.txt '); 
?>

Then a solution would be to make an ajax in your javascript for php and do there, that would be a solution.

Of course this can be done in the same javascript language, but, however, However, you will need to use the javascript on the server side, example to do this is the nodejs, follows a link to do the magic of the Unix command directly from javascript ( with nodejs )

https://nodejs.org/

http://www.dzone.com/snippets/execute-unix-command-nodejs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.