Home
Living the Strange Life
My life with gaming, politics, and technology...
Recent Entries 

Advertisement

Customize
Seashore
This code does two major things. 1). Delete any "stale" videos. 2). Download/update new videos.


@echo off
setLocal

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::
:: Daytime.cmd
:: v1 - And so it begins...
:: v2 - Added more logging, text redirection, and correctly escaped the % sign in the password.
:: v3 - Combined this with the daytime script.
:: v4 - Complete overhaul of script: Intelligent deletion of stale files and intelligent updating.
:: v5 - Updated login segment to deal with login failure.
:: v6 - Fixed error with delimiters.


:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:: Various environmental variables.

set COPYCMD="/y"
set PATH="%WINDIR:"=%\System32"

set SHARE_PATH="%SERVER1:"=%\sales_videos\current"
set DEST_PATH="%USERPROFILE:"=%\My Documents\My Videos"

set LOG="%TMP:"=%/log-daytime.txt"

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

date /t > "%LOG:"=%" 2>&1
time /t >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

echo "Setting power profile to 'Always on'." >> "%LOG:"=%" 2>&1
powercfg /setactive "Always on" >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:SME_Login
echo "Disable connection logging." >> "%LOG:"=%" 2>&1
net use /persistent:"no" >> "%LOG:"=%" 2>&1

:Login_Counter
set /a LOGIN_COUNTER+=1 >> "%LOG:"=%" 2>&1
if %LOGIN_COUNTER:"=% equ 11 (goto end) >> "%LOG:"=%" 2>&1
echo "Login attempt %LOGIN_COUNTER:"=% with SME workgroup server." >> "%LOG:"=%" 2>&1
net use "%SERVER1:"=%" /user:"%SERVER1_USER:"=%" "%SERVER1_PASS:"=%" >> "%LOG:"=%" 2>&1
if %ERRORLEVEL% neq 0 (goto Login_Counter) >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:Stale_Video
echo "Deleting stale/old video's from host machine." >> "%LOG:"=%" 2>&1
for /f "tokens=1* delims=:" %%a in ('dir /b %DEST_PATH%\*.wmv') do (if not exist "%SHARE_PATH:"=%\%%a" (del /f /q "%DEST_PATH:"=%\%%a")) >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:Update_Video
echo "Downloading updated/new video's from network." >> "%LOG:"=%" 2>&1
xcopy /c /d /v /z "%SHARE_PATH:"=%\*.wmv" "%DEST_PATH:"=%" >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:SME_Logoff
echo "Logging off of SME workgroup server." >> "%LOG:"=%" 2>&1
net use /delete "%SERVER1:"=%\IPC$" >> "%LOG:"=%" 2>&1

:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ::

:end
endLocal
@echo on
exit


PS. In the case that anyone is interested, I have the Windows 7 beta!
Mirror
A little background...

Previously when I made plug-ins for Anathema I adhered to the following process:

    Open directory with plugin-fragment.xml.
  1. Select contents of directory.
  2. Compress selection into a ZIP archive.
  3. Change extension to .jar.
  4. Copy JAR to computer downstairs (This machine has VMWare and Windows.)
  5. Run downstairs to use computer.
  6. Open JAR in with 7-zip.
  7. Remove meta-data from JAR. (e.g. .DS_Store, thumbs.db, etc.)
  8. Post JAR for downloading


The average time it took: 8+ minutes.

Now when I make plug-in's for Anathema:

    Open Terminal.
  1. Type sh makeJar.sh
  2. Type name of directory containing plug-in components.
  3. Post JAR for downloading.


The average time it now takes: -1 minute.

makeJar.sh


#!/bin/bash

function createJar {
  printf "Copying files to temporary directory..."
  cp -R $plugDirect pluginTemp ;
  printf "\n Removing meta-data from files..."
  rm -rf $( find pluginTemp -type d -name .svn ) ;
  rm -f $( find pluginTemp -type f -name .DS_Store ) ;
  cd pluginTemp ;
  printf "\n Making $plugDirect.jar..." ;
  jar cf ../$plugDirect.jar * ;
  cd .. ;
  printf "Removing temporary directory..."
  rm -rdf pluginTemp ;
  printf "\n" ;
  printf "\n $plugDirect.jar is finished. \n Look in \'$( pwd )\' for the file." ;
  printf "\n" ;
}

function testDirect {
  if [ -d "$plugDirect" ] ; then
    testJar ;
  else
    read -p "The $plugDirect directory does not exist.  Try again? (y/n)  " noDirect ; 
    if [ $noDirect == "y" ] ; then
      read -p "Please re-ener the directory containing plug-in files:  " plugDirect ;
      testDirect ;
    fi
  fi
}

function testJar {
  if [ ! -f "$plugDirect.jar" ] ; then
    testTemp ;
  else
    read -p "$plugDirect.jar already exists.  Overwrite? (y/n)  " overwriteJar ;
    if [ $overwriteJar == "y" ] ; then
      rm -rdf $plugDirect.jar ;
      testJar ;
    fi
  fi
}

function testTemp {
  if [ ! -d "pluginTemp" ] ; then
    createJar ;
  else
    read -p "pluginTemp already exists.  Overwrite?  (y/n)  " overwriteTemp ;
    if [ $overwriteTemp == "y" ] ; then
      rm -rdf pluginTemp ;
      testTemp ;
    fi
  fi
}

cd /Users/pauladams/Documents/Development/Anathema ;
read -p "Please enter the directory containing the plug-in files:  " plugDirect ;
printf "\n" ;
testDirect ;


Is anyone aware of a way to force characters into the lower case? Y -> y OR N -> n
14th-Sep-2007 10:05 pm - New version of my script...
Seashore
Currently, I’m trying to “bullet proof” (eliminate most potential pitfalls) my script. I’ve added to my script the ability to detect network connectivity (no point in doing online updates if your not online). If it is not found, it will bring up the various network interfaces.

##############################################################################
## This work is licensed under the Creative Commons Attribution-Share Alike ##
## 3.0 United States License. To view a copy of this license, visit         ##
## http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to    ##
## Creative Commons, 171 Second Street, Suite 300, San Francisco,           ##
## California, 94105, USA.                                                  ##
##                                                                          ##
##              risoUpdate.sh Copyright Paul R. Adams, 2007                 ##
##############################################################################

#!/bin/bash

#-- First, replace the current updates.log file with the date.  Second,
#   ask for the administrative password (which is required for software
#   updates and the potential reboot).  Third, export an environmental
#   variable that elminiates any pesky dialog boxes.  Fourth, activate
#   scheduled downloads and append any output (stout and sterr) to the
#   the updates.log file.  Finally, start OS X version specific code bits. --#

date > /tmp/updates.log 2>&1 ;
read -p “Please enter the administration password:  “ Password
export COMMAND_LINE_INSTALL=1 ;
softwareupdate --schedule on >> /tmp/updates.log 2>&1 ;

if [ “$(sw_vers -productVersion | cut -c 1-4)” == “10.4” ] ;
  # -- If OS is 10.4, reset ignored updates. -- #
  then softwareupdate --reset-ignored >> /tmp/updates.log 2>&1 ;
  # -- If OS is 10.3, reset ignored updates. -- #
  else softwareupdate --ignored remove -a >> /tmp/updates.log 2>&1 ;
fi

# -- Do the various network interfaces have IP addresses -- #

if [ -z “$(ifconfig en0 | grep inet)” ] ; 
  then en0_up=”no” ;
  else en0_up=”yes” ;
fi

if [ -z “$(ifconfig en1 | grep inet)” ] ;
  then en1_up=”no” ;
  else en1_up=”yes” ;
fi

if [ -z “$ifconfig en2 | grep inet)” ] ;
  then en2_up=”no” ;
  else en2_up=”yes” ;
fi

# -- If none of the network interfaces have an IP address, bring up the 
#    network interfaces and acquire an IP address. -- #

if (( en0_up==no && en1_up==no && en2_up=no )) ;
  then echo $Password | sudo -S ifconfig en0 up >> /tmp/updates.log 2>&1 ;
  echo $Password | sudo -S ifconfig en1 up >> /tmp/updates.log 2>&1 ;
  echo $Password | sudo -S ifconfig en2 up >> /tmp/updates.log 2>&1 ;
fi

sleep 15 ;

#-- Install all available updates and append any output to updates.log.  Next,
#   update the “prebinding” information for OS X (optimizing step).  Finally,
#   reboot if grep finds “restart” in the updates.log file. -- #

echo $Password | sudo -S softwareupdate -i -a >> /tmp/updates.log 2>&1 ;
echo $Password | sudo -S update_prebinding -root / -force ;
cat /tmp/updates.log | grep restart && echo $Password | sudo -S reboot ;

Advertisement

Customize
This page was loaded Mar 18th 2010, 10:46 am GMT.