Skip to content

Instantly share code, notes, and snippets.

@tgck
Created February 6, 2016 21:45
Show Gist options
  • Save tgck/57bb19af64cc62b4a3ac to your computer and use it in GitHub Desktop.
Save tgck/57bb19af64cc62b4a3ac to your computer and use it in GitHub Desktop.
[osc][oscsend] パイプからoscsend
#!/bin/bash
ADDRESS="127.0.0.1"
PORT="1234"
TAG="/foo/message1"
TYPE=""
function usage() {
echo " Usage: echo message | ${0} "
echo " or : ${0} << (here document) "
exit
}
while read l ; do
args=$l;
#declare -p args
for i in $args
do
if [[ $i =~ ^[0-9]+$ ]] ; then
TYPE=${TYPE}i
elif [[ $i =~ ^[0-9]+\.[0-9]+$ ]] ; then
TYPE=${TYPE}f
elif [[ $i =~ [a-zA-Z] ]] ; then
TYPE=${TYPE}s
fi
done
echo oscsend $ADDRESS $PORT $TAG $TYPE $l | sh;
#echo oscsend $ADDRESS $PORT $TAG $TYPE $l;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment