Portál AbcLinuxu, 30. listopadu 2025 17:01
#!/bin/bash
echo "bla bla bla bla"
/usr/bin/php ?????????????
exit
#### START PHP ####
?php
echo "start \n";
$f = fopen('php://stdin','r');
while (!feof($f))
{
echo fgets($f,1024) . "\n";
}
fclose($f);
echo "stop \n";
?
použitie:
cat data.dat | ./databaza.sh --test
PS: bonusové body pre každého kto to dokáže bez pomocných súborov :D
ďakujem
#!/usr/bin/php
<?php
echo "TEST\n";
for ($i = 1; $i < $argc; $i++)
{
echo "parameter " . $i . ": " . $argv[$i] . "\n";
}
?>prípadne v tom bash skripte vygenerovať html kód a ten poslať (cez rúru) php?
#!/bin/sh NLS_LANG=slovak_slovakia.ee8mswin1250 NLS_NUMERIC_CHARACTERS="." atď. export ORACLE_SID LD_LIBRARY_PATH ... ./import.php $@ <&0
#!/bin/bash
LN=`grep -n '<?php' $0 | tail -1 | awk -F: '{print $1}'`;
LN=$(($LN - 1))
php -f <(sed "$LN,$ !d" $0) -- $@
exit
##### START PHP #####
<?php
echo "STDIN START \n";
$data = fopen('php://stdin','r');
while (!feof($data))
{
echo 'PHP:'.fgets($data,1024);
}
fclose($data);
echo "\n";
echo "STDIN STOP \n";
echo "PARAMETRE \n";
echo print_r($argv,true).'test';
:~/Desktop/TEST$ cat data.dat | ./script.sh -param1 --param2 -test3
STDIN START
PHP:123456
PHP:abcdefgh
PHP:098765432
PHP:test
PHP:endpwd
PHP:
PHP:
STDIN STOP
PARAMETRE
Array
(
[0] => /dev/fd/63
[1] => -param1
[2] => --param2
[3] => -test3
)
#!/bin/bash LN=... php << KONIEC <?php .... ?> KONIEC ...pokracuje bash...
sed "1,/##### START PHP #####/d"
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.