So I finally worked out a method to control my stereo via the command line on my Mac using the IP2IR device I just bought. I tried using this https://www.kolinahr.com/documentation/wagner-ir-extractor/getting-started-with-the-wire-utility/ but it wouldn't run on the Mac out of the box.
However, I used part of this excellent code to come up with this script. This works to turn off my NAD C 356.
A things are needed for this script to work.
- Change the IP address for your IP2IR.
- Install nmap via brew install nmap since ncat doesn't come with the Mac.
- Get the IR code for your device from the Global Cache database.
I'm not a professional programmer but thought this might help someone...
#!/bin/sh
ncat=/usr/local/bin/ncat # brew install nmap
ip=10.0.1.25
port=4998
# create the script for ncat
cat <<'EOF' > /tmp/ir.sh
#!/bin/bash
echo -e -n "$1\r" ; read -t 5 -d $'\r' input ; rc=$?
if [ $rc -ne 0 ]; then input="ERR:$rc, iTach command timeout" ; fi
echo $input > /tmp/ir.out
EOF
chmod a+x /tmp/ir.sh
# IR codes from https://irdb.globalcache.com/Home/Database
off="sendir,1:1,1,38000,1,69,343,172,21,64,21,64,21,64,21,21,22,21,22,21,21,22,21,65,21,21,22,21,22,63,22,63,22,63,22,63,22,63,22,22,21,21,22,21,22,21,21,64,21,21,22,21,22,63,22,63,22,63,22,63,22,63,22,21,21,64,21,64,21,21,22,21,22,1487,342,85,22,1487"
# send the code
cmd="$ncat -w 3 --exec '/tmp/ir.sh $off' $ip $port"
eval $cmd > /dev/null 2>&1
if [ "$?" != "0" ] ; then echo "ERR: could not send IR code." ; exit 1 ; fi
if ! `grep -q completeir /tmp/ir.out` ; then echo "ERR: IR code did not work" ; exit 1 ; fi
# cleanup
rm /tmp/ir.sh /tmp/ir.out > /dev/null 2>&1