View Single Post
Old 18-Nov-2013, 6:44 PM   #27
GroundUrMast
Moderator
 
GroundUrMast's Avatar
 
Join Date: Oct 2010
Location: Greater Seattle Area
Posts: 4,758
Linux Script

Here is a script that works well on a basic Linux box. The function is similar to the Windows batch file in post #5, giving you the function of a PVR/DVR. Edit variable values as needed.

Note that this script also adds tuner locking. This prevents another user, script or application from interrupting the tuner while it's recording. The lock key is the recording time stamp variable, so it's not impossible to override the lock if the need arises.

Use "cron" or "at" to launch the script at the correct time.

Code:
#!/bin/bash
#
#Virtual Channel
VC=5.1

#Real Channel
RCH=48

#Transport Stream Program Number
PROG=3

#Run Time - minutes
RUN_TIME=32

#Recording File Title
TITLE=Test_Recording

#Select Tuner by 'uncommenting' one Tuner
#TUNER=1019D817
#TUNER=101A5A4B
#TUNER=101AE560
TUNER=1032E7DB

#Specify Sub-Tuner, 'tuner0' or 'tuner1'
SUBT=tuner0

#Recording Time Stamp
REC_TS=$(date +"%Y%m%d%H%M")

hdhomerun_config ${TUNER} set /${SUBT}/lockkey ${REC_TS}
hdhomerun_config ${TUNER} key ${REC_TS} set /${SUBT}/channel auto:${RCH}
hdhomerun_config ${TUNER} key ${REC_TS} set /${SUBT}/program ${PROG}
hdhomerun_config ${TUNER} key ${REC_TS} save /${SUBT} /home/tom/Videos/${TITLE}_${REC_TS}.mpg &
HDHR_PID=$!

sleep ${RUN_TIME}m

hdhomerun_config ${TUNER} key ${REC_TS} set /${SUBT}/channel none
hdhomerun_config ${TUNER} key ${REC_TS} set /${SUBT}/lockkey none

kill $HDHR_PID

exit

# Schedule using "at HH:MM MMDDYYYY -f /home/<user_name>/bin/<script_name>
# or use crontab
__________________
If the well is dry and you don't see rain on the horizon, you'll need to dig the hole deeper. (If the antenna can't get the job done, an amp won't fix it.)

(Please direct account activation inquiries to 'admin')

Last edited by GroundUrMast; 7-Jan-2014 at 6:07 AM. Reason: updated script code
GroundUrMast is offline   Reply With Quote