EMBED THIS RECORDING:
<div><script id="playterm-MjAxMi0wNi9jb2RlbWFzaHVwdHR5cmVjLTEzMzg1NDE2Nzl8ODB4MjQ=" type="text/javascript" src="https://playterm.org/js/?hash=MjAxMi0wNi9jb2RlbWFzaHVwdHR5cmVjLTEzMzg1NDE2Nzl8ODB4MjQ=" class="size:80x24"></script></div>
I recorded this `Mashing up code` shellrecording because its a crime to not show people how flexible
bash is.
Hint: type 'man bash'
Code
====
#!/bin/bash
# lets mix some php with bash..
phpcode='
print_r($_SERVER); // ok this could be literally everything..xml,json etc
'
foo(){
echo "mashing up heads!"
(php -r "$phpcode") | while read line; do
# here I can process every line..
# for example to log output in a nice way
printf "output> %sn" "$line"
done
}
"$@"
Coder of Salvation said
Oh..and some possible scenarios where this comes in handy:
- datamining/crawling websites or feeds
- creating a shellscriptcommand which calls a language-specific function (xpath/json_encode/etc)
- using de/encodingfunctions (base64encode/uuencode) from php
- combine, if you are not sure which language to use
- batch processing of files/images using the best of both (language)worlds