RE: Script examples for NT. (yuk!)
Hi Greg, I came to NT world from VMS and was used to DCL. I find the following book a useful reference: Windows NT Shell Scripting 1-57870-047-7 HTH, Sean :) Rookie Data Base Administrator [0%] OCP Oracle8i DBA [0%] OCP Oracle9i DBA Organon (Ireland) Ltd. E-mail: [EMAIL PROTECTED] [subscribed: Digest Mode] Visit: http://groups.yahoo.com/group/Oracle-OCP-DBA Nobody loves me but my mother... and she could be jivin' too. - BB King -- From: Loughmiller, Greg [EMAIL PROTECTED] Date: Wed, 30 May 2001 08:26:45 -0400 Subject: Script examples for NT. (yuk!) Quick question.. ALL of my experience has been on UNIX platforms... Recently, I have been asked to work on an Oracle DB that runs on NT.. My scripting capability in the NT world is weak at best. So I am trying to compare ksh type activities with the NT world. SO I was wondering if any of you would mind sharing a couple of NT type scripts with me.. For example-setting variables to the return of a SQL statement to be used in the shell,etc... Any help would be appreciated.. TIA Greg Loughmiller mailto:[EMAIL PROTECTED] -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: O'Neill, Sean INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
re: Script examples for NT. (yuk!)
http://www.ultratech-llc.com/KB/Scripts/?File=Scripting.BAT (also see bottom of this message for more URLs) http://www.ultratech-llc.com/KB/?File=!Contents.TXT --forwarded message follows-- [Date sent: Wed, 30 May 2001 10:32:11 -0400 To: Recipients of WINNT-L digests [EMAIL PROTECTED] ] -Original Message- From: Andrew S. Baker [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 29, 2001 8:46 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Yet another scripting question However, if the user double clicks the script again, it should not map a new drive, it will only open an Explorer window showing them the contents of the already mapped drive. That will actually require a bit more code than you've used so far, since the ENV variables will not retain enough info between runs. Here's a script using the CD command, which I don't like (for this purpose). Rule #3 in scripting should be to always use the FOR command... :) ~ @ECHO OFF SETLOCAL SET DRIVELIST=z y x w v u t s r q p o n m l k j i h g f e d SET CHECKDRIVE=FALSE FOR %%D IN (%DRIVELIST%) DO CALL :CheckDrive %%D ECHO %CHECKDRIVE% ENDLOCAL GOTO :EOF :CheckDrive rem - %1 = Current Drive Letter CD %1:\ 2NUL IF %ERRORLEVEL% EQU 1 IF /I %CHOSEN%==FALSE SET CHECKDRIVE=%1: GOTO :EOF ~ As a replacement for CD, I chose PUSHD, especially since it already does the first part of what you want (chosing the highest available drive letter). ~ @ECHO OFF SETLOCAL SET RESOURCE=\\COMPUTER\SHARE SET CHECKDRIVE=NOT SET PUSHD %RESOURCE% IF %ERRORLEVEL% EQU 0 FOR /F DELIMS=\ %%D IN ('CD') DO SET CHECKDRIVE=%%D ECHO %CHECKDRIVE% POPD ENDLOCAL ~ Now, if you don't want the drive assigned again, you should check for the existence of the mapping before running the rest of the script See the following: http://www.ultratech-llc.com/KB/Scripts/?File=MapDrive.BAT The full script will be here at some point before tomorrow morning... == ASB - http://www.ultratech-llc.com/KB/?File=Troubleshoot.TXT == --- Forwarded message follows --- Date sent: Wed, 30 May 2001 01:38:54 -0700 Andrew S. Baker wrote: I ended up using PUSHD, since it is native to NT/2000 and does all the work of choosing the highest free drive. ==begin file c:\CMD\TEST\freedrive.cmd == 001. @echo off 002. setlocal 003. set tgt=%1 004. if /i %tgt% NEQ HIGHEST if /i %tgt% NEQ LOWEST ( 005.echo. 006.echo Specify an argument of HIGHEST to return the highest free drive letter 007.echo Specify an argument of LOWEST to return the lowest free drive letter 008.endlocalgoto :EOF 009. ) 010. set free_drives= 011. for %%a in ( 012. z y x w v u t s r q p o n m l k j i h g f e d c b 013. ) do call :test %%a 014. set free_drives=%free_drives:~1% 015. call :%tgt% 016. endlocalset %~n0=%free_drive%goto :EOF 017. 018. :test 019. if exist %1: goto :EOF 020. set free_drives=%free_drives% %1: 021. goto :EOF 022. 023. :lowest 024. for /f tokens=1 delims=: %%a in ( 025. %free_drives% 026. ) do set free_drive=%%a: 027. goto :EOF 028. 029. :highest 030. call :length %free_drives% 031. set /a pos = length - 3 032. call :exec set free_drive=%%free_drives:~%pos%,2%%% 033. goto :EOF 034. 035. :length 036. set S1=%* 037. set length=0 038. :lloop 039. if not defined S1 goto :EOF 040. set S1=%S1:~1% 041. set /a length+=1 042. goto :lloop 043. 044. :exec 045. %* 046. goto :EOF ==end file c:\CMD\TEST\freedrive.cmd == --- End of forwarded message --- http://www.ultratech-llc.com/KB/?File=!Contents.TXT ... SCRIPTING AUTOMATION * http://www.ultratech-llc.com/KB/?File=Assoc.TXT * http://www.ultratech-llc.com/KB/?File=Audit.TXT * http://www.ultratech-llc.com/KB/?File=AutoLogon.TXT * http://www.ultratech-llc.com/KB/?File=BatchJob.TXT * http://www.ultratech-llc.com/KB/?File=Browser.TXT * http://www.ultratech-llc.com/KB/?File=CopyPerms.TXT * http://www.ultratech-llc.com/KB/?File=DateTime.TXT * http://www.ultratech-llc.com/KB/?File=Delegate.TXT * http://www.ultratech-llc.com/KB/?File=DelOld.TXT * http://www.ultratech-llc.com/KB/?File=EnvVars.TXT * http://www.ultratech-llc.com/KB/?File=ERD.TXT * http://www.ultratech-llc.com/KB/?File=InUse.TXT * http://www.ultratech-llc.com/KB/?File=License.TXT * http://www.ultratech-llc.com/KB/?File=Monitoring.TXT * http://www.ultratech-llc.com/KB/?File=NetShell.TXT * http://www.ultratech-llc.com/KB/?File=NTRights.TXT * http://www.ultratech-llc.com/KB/?File=NTVer.TXT * http://www.ultratech-llc.com/KB/?File=OSType.TXT * http://www.ultratech-llc.com/KB/?File=Perms.TXT * http://www.ultratech-llc.com/KB/?File=Processes.TXT *
RE: Script examples for NT. (yuk!)
My suggestion would be to install cygwin (http://sources.redhat.com/cygwin/). -Original Message- From: GLoughmiller [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 30, 2001 8:25 AM To: ORACLE-L Cc: GLoughmiller Subject: Script examples for NT. (yuk!) Quick question.. ALL of my experience has been on UNIX platforms... Recently, I have been asked to work on an Oracle DB that runs on NT.. My scripting capability in the NT world is weak at best. So I am trying to compare ksh type activities with the NT world. SO I was wondering if any of you would mind sharing a couple of NT type scripts with me.. For example-setting variables to the return of a SQL statement to be used in the shell,etc... Any help would be appreciated.. TIA Greg Loughmiller mailto:[EMAIL PROTECTED] -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Loughmiller, Greg INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: Script examples for NT. (yuk!)
You can download CyGWin from Redhat for free that will give you a very nice cloned shell of linux environment, full compatable with Bash/Sh scripting. Wish i could find a ksh shell for it, but it has ALOT of the tools normally available with Unix. ps, kill, grep, tail, head, piping, shell scripts. I will generally write scripts in it and move it to unix with no compatibility problems. Exact url: http://sources.redhat.com/cygwin/ There are many other unix clones for NT, some are great, some are simily a directory with clone commands in it. Walking on water and developing software from a specification are easy if both are frozen. Christopher R. Spence Oracle DBA Fuelspot -Original Message- Sent: Wednesday, May 30, 2001 9:26 AM To: Multiple recipients of list ORACLE-L Quick question.. ALL of my experience has been on UNIX platforms... Recently, I have been asked to work on an Oracle DB that runs on NT.. My scripting capability in the NT world is weak at best. So I am trying to compare ksh type activities with the NT world. SO I was wondering if any of you would mind sharing a couple of NT type scripts with me.. For example-setting variables to the return of a SQL statement to be used in the shell,etc... Any help would be appreciated.. TIA Greg Loughmiller mailto:[EMAIL PROTECTED] -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Loughmiller, Greg INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Christopher Spence INET: [EMAIL PROTECTED] Fat City Network Services-- (858) 538-5051 FAX: (858) 538-5051 San Diego, California-- Public Internet access / Mailing Lists To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).