Git Product home page Git Product logo

ml_shellexec's Introduction

ml_shellexec

ml_shellexec is a module for [Multi Theft Auto: San Andreas] 1 that allows executing commands on Linux servers, and return the output of those commands as a string. This module enables just one serverside function:

string shellexec(string command)

The function will return the output of the executed command as a string, or false if anything went wrong.

The module is based on ml_system, originally developed by x86 [email protected]. Original module allowed executing commands but it returned a boolean value indicating if the command was succesfully executed or not. This version allows checking the output of the executed command instead.

Compiling the module

To compile the module under a 32 bit Debian 6:

$ apt-get install libreadline5-dev libncurses5-dev
$ cd lib/lua51/
$ make linux
$ make install
$ cd ../..
$ make

Alternatively, you can download the precompiled binary file from http://git.pablophg.net/ml_shellexec/downloads/

Installing the module

Place ml_shellexec.so compiled in the previous step on mods/deathmatch/modules on your existing MTA:SA installation. Then open mods/deathmatch/mtaserver.conf and add the following line:

<module src="ml_shellexec.so"/>

Using the module

An example script:

function getServerDate()
    return shellexec('date')
end

local date = getServerDate()
outputChatBox('Server date is: '..date)

That will show something like: Server date is: Mon Nov 10 06:16:11 UTC 2014 on the chat. Of course, it is nothing really useful to just get the date, as you could just use MTA's functions for that; but this module allows doing other interesting things like downloading files using wget, list directories, modify resources, connect to a Redis database, and more. What to use the module for is up to you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.