EMBED YOUR TERMINAL RECORDINGS ONLINE

Mashing up code

DATE: 2012-06-01
AUTHOR: Coder of Salvation
AUTHOR WWW: http://leon.vankammen.eu
RELATED ARTICLE: http://www.google.nl/url?sa=t&rct=j&q=bash...

Related recordings:

CAT COMMAND IN LINUX

tags: cat unix gnu linux view file textfile editing
LIST DIRECTORIES IN LINUX WITH LS

tags: ls directory show content linux disk beginner
SUTRAPHP-INTRODUCTION

tags: sutraphp sutra php console cli eventbased
MORE OVERVIEW IN MYSQL WITH SELECTS

tags: mysql, select, more overview, console
M4, THE HIDDEN GNU TREASURE

tags: m4, gnu, macroprocessor, template, search, replace, sed
THE UNIX TREE COMMAND

tags: unix console tree bash directory listing
DEVTODO: COMMANDLINE TODO MANAGEMEN

tags: todo xml tasks productivity management
VIM ALIGN

tags: vim align aligning text text editing text trick
VISUAL SELECTS IN VIM

tags: vim visual selects regex text editing fast
GENERATING PHP & SQL (MAPPING) CODE

tags: sutra generate sql generate database php cms mysql

Bookmark and Share
EMBED THIS RECORDING:
<div><script id="playterm-MjAxMi0wNi9jb2RlbWFzaHVwdHR5cmVjLTEzMzg1NDE2Nzl8ODB4MjQ=" type="text/javascript" src="http://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

 

Name   
Email (never shown)  
Comment