Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


need help making my VBSCRIPT short

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,35255
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> need help making my VBSCRIPT short
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 need help making my VBSCRIPT short - 6/8/2006 7:55:44 AM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
hi everyone! is there any other way to make my VBSCRIPT short? actually, the script will dump a oracle database twice a day, and will copy the dump and text log to a shared network path, below is the code:

      
any help would be appreciated. thanks!
 
 
Post #: 1
 
 RE: need help making my VBSCRIPT short - 6/8/2006 9:57:17 AM   
  DiGiTAL.SkReAM


Posts: 1183
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: online
Well, there are two schools of thought on this.
1.) Scrunch everything as small as possible, and who cares how unreadable it is.
2.) Utilize a bunch of variables and use them to put together your various lines.

#1 is small
#2 is not as small, but much easier to modify in the future, and a bit easier to read.

#1:

      
Six commands, 7 lines(since I had to wrap line 4 cuz it was too long)

#2:

      
Slightly larger, but - I think - easier to read and understand.


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to blakeph)
 
 
Post #: 2
 
 RE: need help making my VBSCRIPT short - 6/8/2006 10:52:12 AM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
hello DiGiTAL.SkReAM!
 
thank you so much for the effort.
 
great code, seems very advance for me, will try to play with it today.
 
very happy.
blakeph

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 RE: need help making my VBSCRIPT short - 6/8/2006 11:24:41 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
quote:

ORIGINAL: blakeph

hi everyone! is there any other way to make my VBSCRIPT short? actually, the script will dump a oracle database twice a day, and will copy the dump and text log to a shared network path, below is the code:
---snip---
any help would be appreciated. thanks!


One question I have is, why?  There are many cases where more verbose code is a good thing.  I.e. commenting and as DS said, making it easier to read.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to blakeph)
 
 
Post #: 4
 
 RE: need help making my VBSCRIPT short - 7/3/2006 9:40:41 PM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
hi DiGiTAL.SkReAM,

i have a follow-up question regarding my post above, i used the following code to dump the oracle database:

      

but am getting the following error:
-------------
Script: D:\oraex.vbs
Line: 0
char: 1
Error: Path not found
Code: 800A004C
Source: Microsoft VBScript runtime error
-------------
i already checked all my folder paths, and all is pointing to a correct direction.

Thanks.

(in reply to mbouchard)
 
 
Post #: 5
 
 RE: need help making my VBSCRIPT short - 7/4/2006 5:43:09 AM   
  dm_4ever


Posts: 2640
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Unless I'm mistaken you have the same code depending on whether it is the AM or PM. If this is the case, then why not make a sub for the process in the AM and one for the PM.  Actually, since it doesn't appear the dayoftheweek matters since the code is ran depending on whether it is AM or PM, why not get rid of the select statement all together and just use one of the "If dayHourValue < 12 Then else end if" statement. see example below.


      

(in reply to blakeph)
 
 
Post #: 6
 
 RE: need help making my VBSCRIPT short - 7/4/2006 12:53:24 PM   
  DiGiTAL.SkReAM


Posts: 1183
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: online
quote:

ORIGINAL: blakeph

hi DiGiTAL.SkReAM,

i have a follow-up question regarding my post above, i used the following code to dump the oracle database:

      


Try this:

      


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to blakeph)
 
 
Post #: 7
 
 RE: need help making my VBSCRIPT short - 7/4/2006 3:37:39 PM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
quote:

ORIGINAL: dm_4ever

Unless I'm mistaken you have the same code depending on whether it is the AM or PM. If this is the case, then why not make a sub for the process in the AM and one for the PM.  Actually, since it doesn't appear the dayoftheweek matters since the code is ran depending on whether it is AM or PM, why not get rid of the select statement all together and just use one of the "If dayHourValue < 12 Then else end if" statement. see example below.


      


Thanks a lot! I tried your code but, i noticed that it does'nt work if you put the folder path into a variable like this:

      
and will work when i make it like this?

      

< Message edited by blakeph -- 7/4/2006 11:00:30 PM >

(in reply to dm_4ever)
 
 
Post #: 8
 
 RE: need help making my VBSCRIPT short - 7/4/2006 3:39:40 PM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
quote:

ORIGINAL: DiGiTAL.SkReAM



Try this:

      



Thanks a lot! I tried, but am getting the same error. 

< Message edited by blakeph -- 7/4/2006 10:54:10 PM >

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 9
 
 RE: need help making my VBSCRIPT short - 7/4/2006 11:32:15 PM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: offline
Please post the exact code that you are running. Change any IP addresses/usernames/passwords of course but other than that, please post the exact code that is giving you an error.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blakeph)
 
 
Post #: 10
 
 RE: need help making my VBSCRIPT short - 7/4/2006 11:49:12 PM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
Hi! i want to use this code from DiGiTAL.SkReAM, i like it because very short:

      
but am getting the following error message box everytime i ran the above script:
-------------
Script: D:\oraex.vbs
Line: 0
char: 1
Error: Path not found
Code: 800A004C
Source: Microsoft VBScript runtime error
-------------

and below is the temporary code am using right now, and it is working fine.

      

(in reply to ebgreen)
 
 
Post #: 11
 
 RE: need help making my VBSCRIPT short - 7/4/2006 11:57:05 PM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: offline
This is the exact code that gives you the error?


      

And this is all of the code? The reason I ask is that the error message does not sync with the code that is posted. The error message says that there is a file not found error on line 0. Ignoring that there is no line 0, the first line that could potentially produce a file not found error is the .Run line which by my count is line 8. Let's assume that is the offending line. What do you see if you change this line:

CreateObject("Wscript.Shell").Run "%comspec% /c ""E:\ORACLE\ORA90\BIN\EXP.EXE system/opstt@huy file=" & sDumpFile & " log=" & sLogFile & " owner=corttex CONSISTENT=Y""", 0, True

to be these three lines:

strCMD = "%comspec% /c ""E:\ORACLE\ORA90\BIN\EXP.EXE system/opstt@huy file=" & sDumpFile & " log=" & sLogFile & " owner=corttex CONSISTENT=Y"""
MsgBox strCMD
CreateObject("Wscript.Shell").Run strCMD


The goal here is to make sure that the command that is being run is really a valid command.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blakeph)
 
 
Post #: 12
 
 RE: need help making my VBSCRIPT short - 7/5/2006 12:35:27 AM   
  blakeph

 

Posts: 17
Score: 0
Joined: 5/28/2006
Status: offline
hello ebgreen!

i ran your script, and i figured out the error... thanks a LOT to you and to DiGiTAL.SkReAM...:)

blakeph

(in reply to ebgreen)
 
 
Post #: 13
 
 RE: need help making my VBSCRIPT short - 7/5/2006 12:46:44 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: offline
All the credit goes to Digital. I just did what I did best...make someone else's code work. 

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blakeph)
 
 
Post #: 14
 
 RE: need help making my VBSCRIPT short - 7/5/2006 1:55:22 AM   
  DiGiTAL.SkReAM


Posts: 1183
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: online
Just for future reference, when you get an error on "Line 0 Character 1" it is usually the result of having something wrong in an execute or executeglobal string.
For example, I load my includes file with an executeglobal, and if I have an error in my includes file, vbscript doesn't return the actual line, it just says that the error is on Line 0 Character 1.

So what was the error that you corrected?  I am curious as to what was wrong.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to ebgreen)
 
 
Post #: 15
 
 RE: need help making my VBSCRIPT short - 7/5/2006 2:40:51 AM   
  ebgreen


Posts: 4969
Score: 31
Joined: 7/12/2005
Status: offline
I'd be willing to bet that it was a "" problem. Or some other pathing issue in the run command.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 16