How to work with exec?



  • Hello.

    How to write teams exec() And arguments?

    exec("env -i ".$config->get('path_php')." $cli test &>/dev/null &");
    

    or

    exec("fgh/gh -size 350x120 xc:black -font pointsize 70 -fill white -annotate +20+80 'текст' -trim +repage -bordercolor black -border 10 si57825b3af15b5.jpg");
    

    Description of this function: http://php.net/manual/ru/function.exec.php
    There's no word.



  • The PHP mentions this in slippery, as topic actually goes beyond language and interpreter to other programmes and operating systems where the crypt is being implemented.

    De facto, you can launch all of the consolidated programmes that are available in the system to the user from which the programme is being implemented. exec()♪ Although in Windows and other window systems you can start. exec() and graphic programmes. In unix-like systems, such programmes are focused in bin-catalogs. In today ' s UNIX, there are many, hundreds and thousands of them (parts are default, part should be inserted).

    For example, a simple requisition of the current catalogue lswhich may accept parameters -l (list) and -a (indicate everything, including hidden files). If this is about Windows, instead ls -la We can use the team. dir

    <?php
    exec('ls -la', $output);
    echo '<pre>';
    print_r($output);
    

    For exec() more user-friendly shell_exec()

    <?php
    echo nl2br(shell_exec('ls -la'));
    

    Or you could use the back rubber.

    <?php
    echo nl2br(`ls -la`);
    

    The algorithm of developing such a path to the programme or the name of the programme if it is available on a command line without a way (proscribed in the PATH variable environment). There is a further zero, one or more of the programme parameters. The parameter format depends on the programme itself - what it expects as parameters. In some cases, you're pointing out the parameter for his two defisams.

    man --help
    

    Sometimes defiance one.

    ls -h
    

    Sometimes several parameters can be combined into one.

    ls -l -a
    ls -la
    

    Sometimes it doesn't exist.

    eye i
    

    Sometimes after the parameters, the values assigned to the parameters may be

    mysql -h localhost -u root -p
    

    Typically, two defis indicate the full name of the parameter and one abbreviated.

    mysql --host localhost --user root --password
    

    What is the format of the parameters for each team to be examined separately every time, in the 40 years when the programmes have not been written and there is no rigid standard.

    In any operating system, there's a lot of teams available on the command line right after installation. You can study them by studying the command line of your operating system (even UNIX-like systems have different parameters, Windows are quite different from UNIX-mir).

    Actually, it's a really big and interesting subject that doesn't focus on a lot of books. As a starting point, I would advise:

    • Richard Bloom, Christina Bresnahan. Linux command line and scenarios Oh, my God.
    • Eric C. Raymond. Programming Art for Unix

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2