Collection of mostly command line tools / PHP scripts. Somewhat out of date.

⌈⌋ branch:  scripts + snippets


Check-in [63d55e97c1]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Shortened.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:63d55e97c1084917dafbcf03c1e130a6e34f54e5
User & Date: mario 2014-03-21 01:28:20
Context
2014-12-12
19:41
Reworked wrapper script to allow for piping and `-` placeholder parameters, and array functions be called (implicit JSON input/output). check-in: cb3d40f15b user: mario tags: trunk
2014-03-21
01:28
Shortened. check-in: 63d55e97c1 user: mario tags: trunk
01:27
Superseded by <a href="https://fossil.include-once.org/versionnum/">version read/write</a> check-in: 692d0a3f23 user: mario tags: trunk
Changes

Changes to php/PhpFunctionCall.

1
2



3









4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

25
#!/usr/bin/php -qC
<?php













   #-- function name
   $func = $_SERVER["argv"][0];
   $func = substr($func, strrpos($func, "/") + 1);

   #-- args
   $args = $_SERVER["argv"];
   array_shift($args);

   #-- stdin as arg
   if (!count($args)) {
      if (($f = fopen("php://stdin", "rb"))
      and ($input = fread($f, 1<<22))) {
         array_unshift($args, $input);
         fclose($f);
      }
   }

   #-- do
   $output = call_user_func_array($func, $args);
   echo $output;


?>


>
>
>
|
>
>
>
>
>
>
>
>
>

|
<



<



<
<
|
<
<



|
<

>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20

21
22
23


24


25
26
27
28

29
30
31
#!/usr/bin/php -qC
<?php
/**
 * title: shell PHP functions
 * description: allows to invoke PHP functions from the shell
 *
 * Creating symlinks for common function names onto this script
 * allows string functions to be utilized outside of PHP.
 *
 * e.g.
 *       ln -s  PhpFunctionCall base64_decode
 *
 */


   #-- function name
   $func = basename(array_shift($_SERVER["argv"]));


   #-- args
   $args = $_SERVER["argv"];


   #-- stdin as arg
   if (!count($args)) {


      array_unshift($args, file_get_contents("php://stdin"));


   }

   #-- do
   echo call_user_func_array($func, $args);



?>