NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Wishlist v
« Previous 1 … 85 86 87 88 89 … 193 Next »
Recordingstatus.bat parameter cleanup

 
  • 0 Vote(s) - 0 Average
Recordingstatus.bat parameter cleanup
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#1
2007-04-06, 06:52 PM
Sub

Is it possible that you could update the parameters that are passed to recordingstatus.bat please.

Let me explain why. I used to parse %2 in a batch file using batch commands but since I added another tuner it became too complex and the batch commands are very limited, nothing to search a string with for example. I know I could write the string to a temp file and then "find" on the temp file but that's going a bit over the top and it gets messy.

Anyways, I decided to write a simple C# program to do what I need to do which I did very simply. My problem is when I pass the batch %2 as a parameter to my new program it gets messed up, I think because of the spaces and quotation marks.

Example 1
%2 = "0:Digital 1:Recording Coronation Street""1:Antenna:Sleeping""2:Cable:Recording Smallville"
My program gets = 0:Digital 1:Recording Coronation Street"1:Antenna:Sleeping2:Cable:Recording

Example 2
%2 = "0:Digital 1:Sleeping""1:Antenna:Sleeping""2:Cable:Recording Smallville"
My program gets = 0:Digital 1:Sleeping"1:Antenna:Sleeping

In the second example, the 3rd tuner gets missed off altogether.

If it's any help this is my recordingstatus.bat
@echo %DATE% %TIME% %* >> mystatus.log
@echo off
"C:\Program Files\devnz\console\Pundit_Lights.exe" 888 %1 %2 >> mystatus.log

and my 3 tuners are called "Digital 1", "Antenna" and "Cable"

Any help or reformatting of the paremeters would help

BTW, the overall objective being:
1. To turn on a green LED when any recording is going on.
2. To turn on a red LED when it is recording from Cable. This warns the familly to leave the cable box alone.

Cheers
Smeghead
martint123
Offline

Posting Freak

UK, East Yorkshire
Posts: 4,658
Threads: 208
Joined: Nov 2005
#2
2007-04-06, 08:57 PM
smeghead Wrote:2. To turn on a red LED when it is recording from Cable. This warns the familly to leave the cable box alone.

Hmmm, interesting - I'd use a solenoid and flap to cover the IR receiver Big Grin
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#3
2007-04-07, 05:22 AM (This post was last modified: 2007-04-07, 05:43 AM by pBS.)
variables can have a search function, and find can be piped to another command to continue processing...

but i would just use a for loop and compare what's inside the sections..

so to get the 3rd card status, delimit with : and use 7th param...
"0Big Grinigital 1:Sleeping""1:Antenna:Sleeping""2:Cable:Recording Smallville"

Code:
for /f "usebackq tokens=1,2,3,4,5,6,7,8 delims=:" %%F in ('%~2') do echo %%L >>status.txt
Returns- Recording Smallville
here the 7th spot is %%L , second card would be 5 but may also grab the ""0 so we'd have to remove those...

Code:
for /f "usebackq tokens=1,2,3,4,5,6,7,8 delims=:" %%F in ('%~2') do (
set cable=%%L
set ant=%%J
set digit=%%H
)
echo %ant% %digit% %cable%


echo Cable!- %cable% >>status.txt
echo Antenna- %ant:~0,-3% >>status.txt
echo DIgital- %digit:~0,-3% >>status.txt

notice the %digit:~0,-3% part which just cuts off the last 3 chars..Big Grin

just do a 'if not "%%L" EQU "Sleeping" then [.exe to turn on red light]'
or you could just send the params better to your program..Smile

Pundit_Lights.exe %cable% %ant:~0,-3% %digit:~0,-3%
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#4
2007-04-07, 08:47 AM
pBS, thank you very much for your help, I didn't realise that batch files had progressed so far Big Grin

Just one more thing, I'm having a problem with the 'if' statement that you suggested. My batch file is as follows:

---------------------------------------------------------------
@echo off
rem Green Light (bottom) is lamp 0
rem Red Light (top) is lamp 1
rem %1 is a simple Y/N for recording or not
rem %2 is the recording service status

@echo %DATE% %TIME% '%*' >> mystatus.log

if %1 == y goto recording
if %1 == Y goto recording

rem turn both lamps off
"C:\Program Files\devnz\console\parallel_console.exe" 888 0 0
"C:\Program Files\devnz\console\parallel_console.exe" 888 1 0
@echo Both lamps off >> mystatus.log

goto endbatch

:recording

rem turn on lamp 0 as recording something
"C:\Program Files\devnz\console\parallel_console.exe" 888 0 1
@echo Green lamp on >> mystatus.log

rem now its time to work out if the cable is recording something
for /f "usebackq tokens=1,2,3,4,5,6,7,8 delims=:" %%F in ('%~2') do (
set cable=%%L
set ant=%%J
set digit=%%H
)

@echo Cable - %cable% >>mystatus.log
@echo Antenna - %ant:~0,-3% >>mystatus.log
@echo Digital - %digit:~0,-3% >>mystatus.log

if not "%%L" EQU "Sleeping" goto turnredon

rem turn off lamp 1 as cable sleeping
"C:\Program Files\devnz\console\parallel_console.exe" 888 1 0
@echo Red lamp off >> mystatus.log
goto endbatch

:turnredon
rem turn on lamp 1 as recording on cable
"C:\Program Files\devnz\console\parallel_console.exe" 888 1 1
@echo Red lamp on >> mystatus.log

:endbatch
---------------------------------------------------------------


mystatus.log is as follows after setting something to record on digital and then stopping it.

===================
07/04/2007 9:37:02.12 'Y "0Big Grinigital 1:Recording Breakfast""1:Antenna:Sleeping""2:Cable:Sleeping"'
Green lamp on
Cable - Sleeping
Antenna - Sleeping
Digital - Recording Breakfast
Red lamp on
07/04/2007 9:37:12.10 'N "0Big Grinigital 1:Sleeping""1:Antenna:Sleeping""2:Cable:Sleeping"'
Both lamps off
===================


Why does it turn the red lamp on? Cable comes through as sleeping yet it fails the 'if' statement

Thanks again for any help
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#5
2007-04-08, 02:03 AM (This post was last modified: 2007-04-08, 02:08 AM by pBS.)
outside the for loop, %%L is not defined...so use "%cable%"
plus use : for the label..

if not "%cable%" EQU "Sleeping" goto :turnredon

plus you should just run the command from there instead of goto'ing it or "call" it so it will return..
if not "%cable%" EQU "Sleeping" call :turnredon

you can also run 2 commands on one line with && Smile
Code:
if not "%cable%" EQU "Sleeping" "C:\Program Files\devnz\console\parallel_console.exe" 888 1 1 && echo Red lamp on >> mystatus.log
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#6
2007-04-08, 05:00 PM
pBS
Just to let you know I got it working exactly how I want it, thanks for all your help.
pBS
Offline

Posting Freak

Posts: 4,829
Threads: 182
Joined: Aug 2005
#7
2007-04-09, 04:35 AM
Big Grin
batch files have come a long way with just a few added commands...
mostly for-loops..Smile

shoot, i wrote a dvd maker/burner with menus with a batch file...lol
most of the good logic stuff is in there,except for arrays and the like..
almost anything is possible when tie-ing into commands line apps..

otherwise, use Autoit...
Hardware: HDHR Prime, HDPVR 1212, Raspberry pi2, VFD display w/LCDSmartie
pastro
Offline

Posting Freak

Posts: 1,885
Threads: 128
Joined: Jul 2006
#8
2007-04-09, 04:46 AM
martint123 Wrote:Hmmm, interesting - I'd use a solenoid and flap to cover the IR receiver Big Grin

Electrify the remote control.
GBpvr PC: Intel Celeron 1.8 Ghz. 768 Mb WinXp Home Sp2
Video: Diamond 128 Mb 9550
Capture Cards: PVR-150 & PVR-150 MCE w/fm + 2x MVP
Author of: BurnDVDX2 and Skiptool
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Modify Artwork search parameter spin35 4 452 2025-01-16, 04:36 AM
Last Post: spin35
  OID of Capture_Source as Parameter to Parallel-/PostProcessing.bat BrettB 3 1,931 2011-10-06, 04:06 AM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode