May you convert vbscript to shell script?

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat May you convert vbscript to shell script?
# 1  
Old 08-18-2011
May you convert vbscript to shell script?

Dear!
I've a script (vbscript) running on windows machine for along time ago. 2 weeks ago, we changed server from Windows to RHEL5, and this script did not run, and I'm not programmer. So that, I post this script here and wish you convert for me.

vbscript code:
Code:
'This script will:
' - ZIP some source file or dir to %BAK_DEPOT%\BAK_YYYYMMDD.zip

' Loader parameters

Const CCBS_LOG_DIR = "/cloudoracle/app/loadlog/logs/"

Const LOADER_USER=" smart_new_admin/smo20100726@neo60"

Const LOADED_LOGSM_FOLDER = "/cloudoracle/app/loadlog/logs/loaded/"
Const SKIPED_LOGSM_FOLDER = "/cloudoracle/app/loadlog/logs/skiped/"

Const LOADER_CMD_FILE = "./_load_data.sh"
Const ANALYZE_CMD_FILE = "./_analyze_data.sh"
Const ANALYZE_SQL_FILE = "./_analyze_data.sql"

Const PER_CONTROL_FILE = "./_load_perdata.ctl"
Const SEL_CONTROL_FILE = "./_load_seldata.ctl"
Const UPD_CONTROL_FILE = "./_load_upddata.ctl"
Const ERR_CONTROL_FILE = "./_load_errdata.ctl"
Const INV_CONTROL_FILE = "./_load_invdata.ctl"


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
' MAIN-ENTRY
'
'prepareTask
mainTask
'postTask

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
'
'
'--------------------------------------------
' FUNCTIONS
'--------------------------------------------

Function mainTask()
	
Dim oFSO, oLogFolder, oFile
On Error Resume Next

Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oLogFolder = oFSO.GetFolder(CCBS_LOG_DIR)

Dim fYYYYMMDD_
Dim perf_filelist_, sel_filelist_, upd_filelist_
perf_filelist_=""
sel_filelist_=""
upd_filelist_=""

'MsgBox "hello"

Dim maxLoadDate_
maxLoadDate_ = getYYYYMMDD(-1)

For Each oFile in oLogFolder.Files
  
  fYYYYMMDD_ = Left(oFile.Name, 8)

  if (fYYYYMMDD_ <= maxLoadDate_) then
	if (instr(oFile.Name, "per") > 0) then	
		loadData PER_CONTROL_FILE, CCBS_LOG_DIR & oFile.Name
		oFile.Move LOADED_LOGSM_FOLDER		
	elseif (instr(oFile.Name, "sel") > 0) then
		loadData SEL_CONTROL_FILE, CCBS_LOG_DIR & oFile.Name
		oFile.Move LOADED_LOGSM_FOLDER		
	elseif (instr(oFile.Name, "upd") > 0) then
		loadData UPD_CONTROL_FILE, CCBS_LOG_DIR & oFile.Name
		oFile.Move LOADED_LOGSM_FOLDER		
	elseif (instr(oFile.Name, "err") > 0) then
		loadData ERR_CONTROL_FILE, CCBS_LOG_DIR & oFile.Name
		oFile.Move LOADED_LOGSM_FOLDER		
	elseif (instr(oFile.Name, "inv") > 0) then
		loadData INV_CONTROL_FILE, CCBS_LOG_DIR & oFile.Name
		oFile.Move LOADED_LOGSM_FOLDER		
	else
		oFile.Move SKIPED_LOGSM_FOLDER		
	end if
  end if
  
Next

  analyzeData()

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function loadData(control_file, data_file_list)

dim objShell
dim strCommand

set objShell = WScript.CreateObject("Wscript.Shell")

strCommand = LOADER_CMD_FILE & LOADER_USER & " " & control_file & " " & data_file_list
'MsgBox "strCommand: " & strCommand
objShell.run strCommand ,1 ,true

set objShell = nothing

End Function

Function analyzeData()

dim objShell
dim strCommand

set objShell = WScript.CreateObject("Wscript.Shell")

strCommand = ANALYZE_CMD_FILE & LOADER_USER & " @" &ANALYZE_SQL_FILE
'MsgBox "strCommand: " & strCommand
objShell.run strCommand ,1 ,true

set objShell = nothing

End Function


Function getYYYYMMDD(offset)
Dim currDate
currDate = Date() + offset

dim mm_
mm_ = DatePart("m", currDate)
if  mm_ <= 9 then
	mm_ = "0" & mm_
end if

dim dd_
dd_ = DatePart("d", currDate)
if  dd_ <= 9 then
	dd_ = "0" & dd_
end if

Dim sDate
sDate = DatePart("yyyy", currDate) &  mm_ & dd_

getYYYYMMDD = sDate
'getYYYYMMDD = "20101011"

End Function

Thank you very much!
# 2  
Old 08-18-2011
This forum is not a drive-in to get a big part of your work done.
If you try it yourself and get stuck with a particular problem, do not hesitate to ask.
This User Gave Thanks to zaxxon For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert the SQL Query in Shell Script

Hi All, I have a query with output below select 'create synonym "'||TABLE_NAME||'" for '||Table_owner||'."'||table_name||'"'||chr(59) from user_synonyms; ================== create synonym "RV_SBC_SIG" for WFCONTROLLER_TE."RV_SBC_SIG"; create synonym "AQM_TASK" for AWQM_TE."AQM_TASK";... (2 Replies)
Discussion started by: pvmanikandan
2 Replies

2. Shell Programming and Scripting

Convert my shell script to C programming HELP!!

I had try to create a basic shell script. So now im trying to convert in to C-programming language can some one guide/help me out with it?(BTW IM USING A LINUX/UNIX/ORACLE SYSTEM) CODE BELOW !/bin/bash for i in `ls -1 /cslab/home/JAZEL/` do cp -uv $i /cslab/home/JAZEL/cs295/$i.`date... (2 Replies)
Discussion started by: Nygenesis
2 Replies

3. Shell Programming and Scripting

Convert shell script to Perl

Hello,,I have a very small script that contains these lines; and it works perfectly; however I need to use Perl now as I will need to feel variables from a MySQL table into this; to it would be nice to start by converting this first... find / -perm 777 \( -type f -o -type d \) -exec ls -lid {}... (1 Reply)
Discussion started by: gvolpini
1 Replies

4. Shell Programming and Scripting

convert to shell script

how to convert these code to shell script #include<stdio.h> #include<conio.h> main() { int i,j,a=0,b=0,c=0,f,t,al,ta; int a1, max, n, n1,p,k=0; printf(“\n enter no.of resources”); scanf(“%d”,n1); printf(“\nenter the max no .of resources for each type”); for(i=0;i<n1;i++)... (4 Replies)
Discussion started by: syah
4 Replies

5. Shell Programming and Scripting

how to convert a shell script to a php script for displaying next word after pattern match

I have a shell script which I made with the help of this forum #!/bin/sh RuleNum=$1 cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}' Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
Discussion started by: sb245
0 Replies

6. UNIX for Dummies Questions & Answers

Calling Bourne .sh Script with Windows VBScript

Is it possible to call and execute a Bourne .sh script from within a Windows VBScript? When the shell script sucessfully completes the VBScript continues to the next step. (2 Replies)
Discussion started by: PaulJay
2 Replies

7. Shell Programming and Scripting

please convert the below program into shell script

if ( ( grep -i "Exception : " /home/dklog* )) then echo " improper combination" elsif ( ( grep -i "invalid" /home/dklog*)) then echo " wrong process " fi fi in the above case i am facing the the syntx error please help in this case... (3 Replies)
Discussion started by: mail2sant
3 Replies

8. Shell Programming and Scripting

convert cpp program to c shell script ?

Hi guys I tried to convert this c++ code to c shell script but there are some bugs and I don't know how to solve it. This code prints the three variables in decreasing order: int main() { int x,y,z; cin >> x >> y >>z; if ( x < y ) if ( x < z ) if ( y < z ) cout << x <<" " <<... (2 Replies)
Discussion started by: domain
2 Replies

9. UNIX for Advanced & Expert Users

Shell script to convert to Title case

I need a shell script which will convert the given string to Title case. E.g "hi man" to "Hi man" (5 Replies)
Discussion started by: SankarV
5 Replies

10. Shell Programming and Scripting

Convert shell script for looping

Situation: I have a working shell script on our file server (OSXS Tiger) to connect to a workstation, which is using a portable home directory (phd), and rsync a user's MirrorAgent.log. I'm not that strong of a scripter (obviously), but I would like to add other workstations to this script as they... (4 Replies)
Discussion started by: le0pard13
4 Replies
Login or Register to Ask a Question