PDA

View Full Version : standby command from telnet?



loveman
02-09-2008, 10:32 PM
Hi.

After getting the loadepg running to get epg data, I've written a script to be run by cron nightly to update the epg data.

Script seems to be running fine, but ideally I'd like to set the box to standby after it's finished running the command.

This is the script I've setup so far:



#!/bin/sh
#Script to update the EPG cache file create by e2_loadepg
#Script designed and written by pooface

LOADEPGDIR=/media/usb/e2_loadepg
LOADEPGEXE=e2_loadepg.py
CACHESRC=/media/usb/e2_loadepg/cache
LOGARCHIVE=/media/usb/e2_loadepg/logs
LOGFILE=e2_loadepg.log
DATESUFFIX=$( date +%m%d%Y)

# Move the log file into the archive, first checking that there is no log created previously
if test -f $LOGARCHIVE/$LOGFILE.$DATESUFFIX ; then
rm $LOGARCHIVE/$LOGFILE.$DATESUFFIX
fi
if test -f $LOADEPGDIR/$LOGFILE ; then
cp $LOADEPGDIR/$LOGFILE $LOGARCHIVE/$LOGFILE.$DATESUFFIX
fi

# Remove the cache files
rm $CACHESRC/*

# Run the loadepg executable
$LOADEPGDIR/$LOADEPGEXE

# Restart Enigma2
killall -9 enigma2


My scripting isn't so hot, but pleased that got this up and running in about 10 mins :)

So basically, what I want to do is after the restart enigma command, is set the box to go to standby (to stop using power, and also to stop using network so much ;)).

Any idea how I can do this?

Cheers :)

loveman
03-09-2008, 01:02 PM
OK, have managed to do it :)

For anyone wanting similar, this is my code:

epg_update.sh


#!/bin/sh
#Script to update the EPG cache file create by e2_loadepg
#Script designed and written by pooface

LOADEPGDIR=/media/usb/e2_loadepg
LOADEPGEXE=e2_loadepg.py
CACHESRC=/media/usb/e2_loadepg/cache
LOGARCHIVE=/media/usb/e2_loadepg/logs
LOGFILE=e2_loadepg.log
DATESUFFIX=$( date +%m%d%Y)
STANDBY=standby.py

# Move the log file into the archive, first checking that there is no log created previously
if test -f $LOGARCHIVE/$LOGFILE.$DATESUFFIX ; then
rm $LOGARCHIVE/$LOGFILE.$DATESUFFIX
fi
if test -f $LOADEPGDIR/$LOGFILE ; then
cp $LOADEPGDIR/$LOGFILE $LOGARCHIVE/$LOGFILE.$DATESUFFIX
fi

# Remove the cache files
rm $CACHESRC/*

# Run the loadepg executable
$LOADEPGDIR/$LOADEPGEXE

# Restart Enigma2
killall -9 enigma2

# Wait for enigma2 to finished loading
sleep 120

# Send Dreambox to standby mode.
$STANDBY


standby.py


#!/usr/bin/python
# Code to put the dreambox in standby mode using the Web Interface.
# For this to work, please ensure you have enabled the webinterface
# on your box, and and no authentication specified.

import urllib2

def WebIf(command):

try:
sock=urllib2.urlopen('http://127.0.0.1/web/' + command)
data=sock.read()
except urllib2.URLError:
pass
except urllib2.HTTPError:
pass
except urllib2.httplib.BadStatusLine:
pass
else:
sock.close()
return(data)

WebIf('powerstate?newstate=0')

mini__me
03-09-2008, 02:45 PM
Nice one :-)

Will stick this on when I get back later this week!!