User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » My batch file is broken :( Page [1]  
wwwebsurfer
All American
10217 Posts
user info
edit post

This section of code launches a series of programs (Sony Vegas render nodes for network rendering) but it only launches one at a time and waits for the previous to close before launching the next. When I was testing I hardcoded in 4 launch commands and got 4 running programs, but when I try to do it dynamically using this loop it doesn't work out.

Quote :
"ECHO Launching Nodes...
SET /A counter=0
SET progLaunch=%progDir%\%progExe%
:launchLoop
IF %counter% EQU %numNodes% GOTO exitLaunch
SET /A counter=%counter%+1
ECHO launching instance for node %counter%...
%progLaunch% -nosave -config %progDir%\netConfigFiles\client%counter%.config
GOTO launchLoop
:exitLaunch"



Here's the full code if anyone needs network rendering for Vegas. It works on any edition - just fill in the directory and the program file name.

Quote :
"@ECHO OFF
cls
::Script to create Vegas 8.0 Render Nodes
:lease open the firewall in advance!
:done by program permissions or port 53704+(n-1) where n is number of nodes)
::
::What this script does
::Creates a directory to hold config files
::Creates the necessary number of config files (by parameter or # of processors)
::Each config has it's own sequential port number
::Spawns necessary number of nodes
::Spawns task manager, reports back IP address
::Waits for you to render
::On close -> wipes out all render instances, wipes svr instances,
::wipes config files, wipes directory

:efine location of Vegas
::----------CHANGE THESE VARIABLES----------
SET progDir="C:\Program Files\Sony\Vegas Pro 8.0"
ECHO Base Program Directory.............%progDir%
SET basePort=53704
ECHO Base Port..........53704
SET progExe=VegSrv80.exe
::----------END CHANGE VARIABLES----------

:efine number of nodes
IF [%1] EQU [] (SET numNodes=%NUMBER_OF_PROCESSORS%) ELSE (SET numNodes=%1)
ECHO Firing up %numNodes% nodes...

::Lets drag out that IP address
ipconfig > c:\iphelper.txt
find "IP Address" c:\iphelper.txt
del c:\iphelper.txt

::Create directory to hold all the configs
mkdir %progDir%\netConfigFiles

::Create configs
SET /A counter=0
:configLoop
IF %counter% EQU %numNodes% GOTO exitConfig
SET /A counter=%counter%+1
SET /A port=%basePort%+%counter% -1
ECHO making config for node %counter%...
ECHO ^<configuration^> > %progDir%\netConfigFiles\client%counter%.config
ECHO ^<system.runtime.remoting^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<application^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<service^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<wellknown >> %progDir%\netConfigFiles\client%counter%.config
ECHO mode="Singleton" >> %progDir%\netConfigFiles\client%counter%.config
ECHO type="Sony.Vegas.NetRender.NetRenderService,Sony.Vegas.NetRender" >> %progDir%\netConfigFiles\client%counter%.config
ECHO objectUri="NetRenderService.rem" >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^/^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<^/service^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<channels^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<channel name="NetRenderService" ref="tcp" port="%port%"^/^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<^/channels^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<lifetime leaseTime="0" ^/^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<^/application^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<^/system.runtime.remoting^> >> %progDir%\netConfigFiles\client%counter%.config
ECHO ^<^/configuration^> >> %progDir%\netConfigFiles\client%counter%.config
GOTO configLoop
:exitConfig

ECHO Launching Nodes...
SET /A counter=0
SET progLaunch=%progDir%\%progExe%
:launchLoop
IF %counter% EQU %numNodes% GOTO exitLaunch
SET /A counter=%counter%+1
ECHO launching instance for node %counter%...
%progLaunch% -nosave -config %progDir%\netConfigFiles\client%counter%.config
GOTO launchLoop
:exitLaunch

ECHO Holding until you're ready to shut 'er down (ON KEY PRESS EVERYTHING DIES!!!)

PAUSE

ECHO Wiping everything out
del /Q %progDir%\netConfigFiles
rmdir /Q %progDir%\netConfigFiles
ECHO We're done here...

PAUSE"

5/18/2011 6:38:36 PM

Prospero
All American
11662 Posts
user info
edit post

Quote :
"shut 'er down"

5/18/2011 6:51:16 PM

wwwebsurfer
All American
10217 Posts
user info
edit post

^haha, I got all excited that it was answered already.

These documentation notes are for our editors. They enjoy little things like that

5/18/2011 6:55:50 PM

Shaggy
All American
17820 Posts
user info
edit post

whoa whoa, you got smilies all up in that thing. no wonder it doesnt work.

also, what happens if you throw a start infront of proglaunch?

Quote :
"
start %progLaunch% -nosave -config %progDir%\netConfigFiles\client%
"

5/18/2011 10:22:50 PM

qntmfred
retired
40812 Posts
user info
edit post

Quote :
"start infront of proglaunch"


that was my first thought

actually, my first thought was powershell > .bat

5/18/2011 10:29:07 PM

smoothcrim
Universal Magnetic!
18968 Posts
user info
edit post

also, try swapping
SET /A counter=%counter%+1
to
SET /A counter+=1

5/18/2011 11:28:03 PM

wwwebsurfer
All American
10217 Posts
user info
edit post

Dangit, I am not at work any more but I bet start will fix it. That's what I get looking at this stupid script for like 3 hours. I kept trying to use bash commands and breaking it....

Will report back.

5/18/2011 11:52:26 PM

wwwebsurfer
All American
10217 Posts
user info
edit post

bah.... it appears start uses space as a delimiter. So I put it into it's own string and start on the string - and all I get is a blank command prompt

[Edited on May 19, 2011 at 10:10 AM. Reason : nope... start sees quotes as a window title. Stupid thing...]

5/19/2011 10:09:45 AM

wwwebsurfer
All American
10217 Posts
user info
edit post

After a few hours this morning the only way I could get it to work is to dynamically create some batch files and launch each of those.

If anyone cares, here's the working code:
Quote :
"@ECHO OFF
cls
::Script to create Vegas 8.0 Render Nodes
:lease open the firewall in advance!
:done by program permissions or port 53704+(n-1) where n is number of nodes)
::
::What this script does
::Creates a directory to hold config files
::Creates the necessary number of config files (by parameter or # of processors)
::Each config has it's own sequential port number
::Spawns necessary number of nodes
::Spawns task manager, reports back IP address
::Waits for you to render
::On close -> wipes out all render instances, wipes svr instances,
::wipes config files, wipes directory

:efine location of Vegas
::----------CHANGE THESE VARIABLES----------
SET progDir=C:\Program Files\Sony\Vegas Pro 8.0
ECHO Base Program Directory.............%progDirQuotes%
SET basePort=53704
ECHO Base Port..........53704
SET progExe=VegSrv80.exe
::----------END CHANGE VARIABLES----------

SET progDirQuotes="%progDir%"

:efine number of nodes
IF [%1] EQU [] (SET numNodes=%NUMBER_OF_PROCESSORS%) ELSE (SET numNodes=%1)
ECHO Firing up %numNodes% nodes...

::Lets drag out that IP address
IPCONFIG > c:\iphelper.txt
FIND "IP Address" c:\iphelper.txt
DEL c:\iphelper.txt

::Create directory to hold all the configs
MKDIR %progDirQuotes%\netConfigFiles

::Create configs
SET /A counter=0
:configLoop
IF %counter% EQU %numNodes% GOTO exitConfig
SET /A counter=%counter%+1
SET /A port=%basePort%+%counter% -1
ECHO making config for node %counter%...
ECHO ^<configuration^> > %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<system.runtime.remoting^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<application^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<service^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<wellknown >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO mode="Singleton" >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO type="Sony.Vegas.NetRender.NetRenderService,Sony.Vegas.NetRender" >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO objectUri="NetRenderService.rem" >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^/^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<^/service^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<channels^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<channel name="NetRenderService" ref="tcp" port="%port%"^/^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<^/channels^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<lifetime leaseTime="0" ^/^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<^/application^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<^/system.runtime.remoting^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
ECHO ^<^/configuration^> >> %progDirQuotes%\netConfigFiles\client%counter%.config
GOTO configLoop
:exitConfig

ECHO Launching Nodes...
SET /A counter=0
SET progLaunch=%progDir%\%progExe%

:launchLoop
IF %counter% EQU %numNodes% GOTO exitLaunch
SET /A counter=%counter%+1
ECHO launching instance for node %counter%...
ECHO "%progLaunch%" -nosave -config "%progDir%\netConfigFiles\client%counter%.config" > launch%counter%.bat
START /MIN "node%counter%" launch%counter%.bat
GOTO launchLoop
:exitLaunch

ECHO Holding until you're ready to shut 'er down (ON KEY PRESS EVERYTHING DIES!!!)

PAUSE

ECHO Are you sure? This will kill all processes and end the party

PAUSE

ECHO Wiping everything out
::kill tasks
ECHO Killing Nodes...
SET /A counter=0
:killLoop
IF %counter% EQU %numNodes% GOTO exitKill
SET /A counter=%counter%+1
ECHO killing instance for node %counter%...
TASKKILL /f /t /fi "WINDOWTITLE EQ node%counter% - launch%counter%.bat"
DEL /Q launch%counter%.bat
GOTO killLoop
:exitKill

::wipe config files
del /Q %progDirQuotes%\netConfigFiles
::wipe directory
rmdir /Q %progDirQuotes%\netConfigFiles
ECHO We're done here, exiting...

PAUSE"

5/19/2011 11:09:00 AM

BIGcementpon
Status Name
11319 Posts
user info
edit post

Using the code button (#) should avoid random .

@ECHO OFF
cls
::Script to create Vegas 8.0 Render Nodes
:lease open the firewall in advance!
:done by program permissions or port 53704+(n-1) where n is number of nodes)
::
::What this script does
::Creates a directory to hold config files
::Creates the necessary number of config files (by parameter or # of processors)
::Each config has it's own sequential port number
::Spawns necessary number of nodes
::Spawns task manager, reports back IP address
::Waits for you to render
::On close -> wipes out all render instances, wipes svr instances,
::wipes config files, wipes directory


[Edited on May 19, 2011 at 5:11 PM. Reason : Too bad it doesn't ]

5/19/2011 5:09:20 PM

wwwebsurfer
All American
10217 Posts
user info
edit post

^what?

5/19/2011 5:50:21 PM

lewisje
All American
9196 Posts
user info
edit post

use the italic tags [i][/i] to avoid random emoticons, like :P instead of

5/19/2011 11:20:12 PM

wwwebsurfer
All American
10217 Posts
user info
edit post

^that would be a colossal misappropriation of my free time.

5/20/2011 10:07:47 AM

 Message Boards » Tech Talk » My batch file is broken :( Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.