Results 1 to 3 of 3

Thread: Batch file for Private network Sneaker-Netting

  1. #1
    Member
    Join Date
    May 2003
    Location
    Portland, OR USA
    Posts
    79

    Batch file for Private network Sneaker-Netting

    I had begun to work really hard on making this generic enough to run on nearly anyone's private network, but it started to get cumbersone. I'll just describe my network and you can build your own script from snippets of my code, if you like.

    I've got a whole bunch of folding clients, so I prefer to harvest just a few of them at a time. Once I got this program working, I found that I could run several instances of it in different directories (with different drive letter assignments in each, of course) to harvest several machines concurrently. If you've just got a couple of clients, replace the Starting IP address and Ending IP address prompts with unprompted SET commands, or for that matter, you can globally replace the variables with the appropriate values. I run this script with the account of an Administrator.

    Most of my Distributed Folding Clients keep their work in D:\distribfold or C:\distribfold. A few Clients have multiple CPUs and/or HyperThreading. I keep their work in D:\distribfold1, D:\distribfold2, etc. This script will check all appropriate drives and folders for work rather than try to guess which machine got what IP address. I suppose I could find some way to make it more generic and check drives E:, F:, G:, etc., but I don't need that in my folding farm. My harvesting program runs in the directory D:\DJP\HARVEST. This will probably have to be edited to run on your network.

    The program called sleep.exe takes a command-line argument and pauses for that number of seconds. There are plenty of similar programs out there. Pick the one you like.

    Did I mention the fact that you will need to modify this script to fit your network?

    Code:
    @echo off
    REM Harvest a Private Network's Phase II Distributed Folding Clients
    REM This runs fine on a Windows 2000 machine. It should also work
    REM in WinXP, but there may be some trouble if you try with NT4 or
    REM Win9x operating systems
    ECHO.
    ECHO.
    IPCONFIG
    ECHO.
    ECHO Verify that the uploader is connected to both the private net
    ECHO and the Internet and then
    PAUSE
    SET HANDLE=4s8cy36
    SET /P IPADDR="Starting IP address?"
    ECHO. 
    SET /P STOPVAL="Ending IP address?"
    ECHO.
    SET /P AUSER="Administrative Username?"
    ECHO.
    SET /P APASS="Administrative Password?"
    ECHO.
    DEL /P HARVEST.LOG
    
    :MACHINE
    NET USE L: /DELETE
    SET TARGET=192.168.1.%IPADDR%
    ECHO %TARGET%
    REM Test to see if there’s a machine at this IP address
    REM before trying to mount a network share
    PING -N 1 %TARGET% >NUL:
    PING -N 1 %TARGET% | FIND /C "Reply from" >NUL:
    IF %ERRORLEVEL% EQU 1 GOTO NEXTMACHINE
    REM If I knew a good test for which machines don’t have 
    REM work on the C: drive, I would insert something here
    REM like IF <test> GOTO DSTART before wasting time
    REM with a network mount of the client’s C: drive
    NET USE L: \\%TARGET%\C$ /USER:%AUSER% %APASS%
    IF NOT EXIST L:\*.* GOTO NEXTMACHINE
    SET INDEX=0
    SET DDIR=distribfold
    
    :CLOOP
    REM hit the next directory if there’s no work waiting in this one
    IF NOT EXIST L:\%DDIR%\FILELIST.TXT GOTO NEXTCLOOP
    REM Ready to stop the folding client, whether it’s running or not
    DEL L:\%DDIR%\FOLDTRAJLITE.LOCK
    
    :HOLD1
    D:\DJP\HARVEST\SLEEP.EXE 2
    IF EXIST L:\%DDIR%\PROGRESS.TXT GOTO HOLD1
    
    D:\DJP\HARVEST\SLEEP.EXE 3
    D:
    CD \
    CD DJP
    CD HARVEST
    REM Ready to move files
    MOVE L:\%DDIR%\FILELIST.TXT .
    MOVE L:\%DDIR%\ERROR.LOG .
    MOVE L:\%DDIR%\%HANDLE%*.* .
    MOVE L:\%DDIR%\FOLD_*.* .
    REM
    REM Copy Statistics - This is optional
    ECHO %TARGET% >> HARVEST.LOG
    TYPE FILELIST.TXT >> HARVEST.LOG
    ECHO. >> HARVEST.LOG
    ECHO. >> HARVEST.LOG
    ECHO. >> HARVEST.LOG
    REM Ready to Upload
    .\foldtrajlite -f protein -n native -ut -rt
    REM upload completed
    REM Copy more optional statistics after uploading
    TYPE FILELIST.TXT >> HARVEST.LOG
    MOVE FILELIST.TXT  L:\%DDIR%
    MOVE %HANDLE%*.* L:\%DDIR%
    MOVE FOLD_*.* L:\%DDIR%
    REM files are returned to the client
    
    
    :NEXTCLOOP
    SET /a INDEX=%INDEX% +1
    REM my multi-processor boxes have at most 4 
    REM CPUs dedicated to Distributed Folding,
    REM so I’ll only check 4 directories for work
    IF %INDEX% GTR 4 GOTO DSTART
    SET DDIR=DISTRIBFOLD%INDEX%
    GOTO CLOOP
    
    
    :DSTART
    NET USE L: /DELETE
    REM If I knew a good test for which machines don’t have 
    REM work on the D: drive, I would insert something here
    REM like IF <test> GOTO NEXTMACHINE before wasting 
    REM time with a network mount of the client’s C: drive
    NET USE L: \\%TARGET%\D$ /USER:%AUSER% %APASS%
    IF NOT EXIST L:\*.* GOTO NEXTMACHINE
    SET INDEX=0
    SET DDIR=distribfold
    
    :DLOOP
    IF NOT EXIST L:\%DDIR%\FILELIST.TXT GOTO NEXTDLOOP
    REM Ready to stop the folding client
    DEL L:\%DDIR%\FOLDTRAJLITE.LOCK
    
    :HOLD2
    D:\DJP\HARVEST\SLEEP.EXE 2
    IF EXIST L:\%DDIR%\PROGRESS.TXT GOTO HOLD2
    
    D:\DJP\HARVEST\SLEEP.EXE 1
    D:
    CD \
    CD DJP
    CD HARVEST
    REM Ready to move files
    MOVE L:\%DDIR%\FILELIST.TXT .
    MOVE L:\%DDIR%\ERROR.LOG .
    MOVE L:\%DDIR%\%HANDLE%*.* .
    MOVE L:\%DDIR%\FOLD_*.* .
    REM
    REM Copy Statistics - This is optional
    ECHO %TARGET% >> HARVEST.LOG
    TYPE FILELIST.TXT >> HARVEST.LOG
    ECHO. >> HARVEST.LOG
    ECHO. >> HARVEST.LOG
    ECHO. >> HARVEST.LOG
    REM Ready to Upload
    
    .\foldtrajlite -f protein -n native -ut -rt
    REM upload completed
    REM Copy more optional statistics
    TYPE FILELIST.TXT >> HARVEST.LOG
    MOVE FILELIST.TXT  L:\%DDIR%
    MOVE %HANDLE%*.* L:\%DDIR%
    MOVE FOLD_*.* L:\%DDIR%
    REM files are returned to the client
    
    :NEXTDLOOP
    SET /A INDEX=%INDEX% +1
    REM my multi-processor boxes have at most 4 
    REM CPUs dedicated to Distributed Folding,
    REM so I’ll only check 4 directories for work
    IF %INDEX% GTR 4 GOTO NEXTMACHINE
    SET DDIR=DISTRIBFOLD%INDEX%
    GOTO DLOOP
    
    :NEXTMACHINE
    SET /A IPADDR=%IPADDR% +1
    IF %IPADDR% GTR %STOPVAL% GOTO END
    D:
    GOTO MACHINE
    
    :END
    D:
    CD \
    CD DJP
    CD HARVEST
    NET USE L: /DELETE
    Last edited by djp; 07-02-2003 at 07:40 PM.
    -djp
    I'm not a Stats Ho either. I just want to go and check to see that all my spare boxen are busy. Hang on a minute....

  2. #2
    Fixer of Broken Things FoBoT's Avatar
    Join Date
    Dec 2001
    Location
    Holden MO
    Posts
    2,137
    cool

    next time, check the "Disable Smilies in This Post " so your code doesn't turn into



    thanks for the info
    Use the right tool for the right job!

  3. #3
    Member
    Join Date
    May 2003
    Location
    Portland, OR USA
    Posts
    79
    Aarrrggghhh! I knew I forgot something.

    There it's diasbled.
    -djp
    I'm not a Stats Ho either. I just want to go and check to see that all my spare boxen are busy. Hang on a minute....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •