how to call a .bat file using KSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to call a .bat file using KSH
# 1  
Old 01-08-2009
how to call a .bat file using KSH

Hi all,

I am a very new user for korn scripting and in a process of learning.
i have a .bat file that calls a .vbs file which calls a macro used to convert an excel spread sheet to .csv file...
Now i want to automate this process. I want to call this bat file using a korn script or a korn script that runs my .vbs file...
can anyone say me how to do that
the .bat and .vbs files are on windows. Even the created new .cvs file is also placed on windows.
Below code cotains my .bat and .vbs files

.bat

Code:
start /w wscript.exe \\pb-a-024\xyz.vbs
.vbs

Code:
Dim xlApp, xlBook, xlSht Dim filenamefilename = "\\pb-a-024\xyz.xls"Set xlApp = CreateObject("Excel.Application")set xlBook = xlApp.WorkBooks.Open(filename)set xlSht = xlApp.activesheet'xlBook.Close FalsexlApp.Quit'always deallocate after use...set xlSht = Nothing Set xlBook = NothingSet xlApp = Nothing
# 2  
Old 01-08-2009
I'm not sure if I understand that...
You have ksh from cygwin running on windows machine and want to execute external command (in this case a bat file)?
# 3  
Old 01-08-2009
By adding ". ./file1.bat" in the shell script will execute file1.bat
# 4  
Old 01-08-2009
Thanks... but can you be more detail... i dont a bit about Unix apart from how to execute a script...

can you say me how should i give the path of the batfile....since the bat file is on windows...
i just want a korn script that will trigger and start the bat file.... and the out put is also generated to windows.... so the korn script have to just trigger the bat file...
Please be detail as my knowledge is very low on Unix

Thanks!
# 5  
Old 01-08-2009
I am sorry i dint understand what your question is...

Thanks!
# 6  
Old 01-08-2009
What adderek asked you is the version of Unix you are using.

Cygwin is a desktop version of Unix.
# 7  
Old 01-09-2009
Thanks!

I am sorry for not being clear...Well we dont have Cygwin and i dont i can get that also....

Actually the unix box and windows (windows XP Sp2, MS office 2003) are on different servers (I think so). I wrote a script to FTP a file form windows to unix and its working...

Code:
STEP_NUM="30"
STEP_NAME="FTP Files "
Log_Step_Begin
FTP_FILE_NAME="LTC*.csv"
FTP_DIR_NAME="ProviderReject"
ONE_MORE="Notification_Reports"
PRESENT_DIR=`pwd`
FTP_STATS="${LOG_DIR}/FTP_Provider_Rej.stats"
FTP_ERR="${LOG_DIR}/FTP_Provider_Rej.error"
ftp -nv ${SI_NOTIFICATION_FTP_IP} > ${FTP_STATS} 2> ${FTP_ERR} <<EOF 
user ${SI_NOTIFICATION_FTP_USER} ${SI_NOTIFICATION_FTP_PASSWORD}
cd ${ONE_MORE}
cd ${FTP_DIR_NAME} 
bin
lcd ${DATA_DIR}
pwd
dir
prompt off
mget ${FTP_FILE_NAME}  
mdelete ${FTP_FILE_NAME}
prompt on
dir
EOF
if [[ -f $FTP_ERR ]] && [[ ! -s $FTP_ERR ]]     
then                                            
  rm -f ${FTP_ERR}                              
fi                                              
CURRENT_DIR=`pwd`
echo 1
echo $`pwd`
cd ${DATA_DIR}
echo 2
echo $`pwd`
FTP_FILE_NAME=`ls | grep $FTP_FILE_NAME` 
UNIX_FILE_NAME="${FTP_FILE_NAME%.*}".dat
echo 3
echo $`pwd`
cd $CURRENT_DIR
echo 4
echo $`pwd`
if [[ ! -f ${DATA_DIR}/${FTP_FILE_NAME} ]]     
then
     print "\n FILE NOT  FOUND ! \n" >> ${SCRIPT_LOG_FILE}
     SUBJ="${SCRIPT_NAME} CSV FILE  NOT FOUND for ${CUR_MAINT_DATE}"
     MSG="File Not found .  Runtime=$(Elapsed_Time ${START_TIME})"
     echo "${MSG}" | mailx -s"${SCRIPT_RUN_ENV} - ${SUBJ}" `cat ${ANALYST_EMAIL_FILE}`
       
     if [ ! -d ${LOG_DIR}/${CUR_MAINT_DATE} ]  
     then                                       
       mkdir ${LOG_DIR}/${CUR_MAINT_DATE}     
     fi                                         
      mv -f ${SCRIPT_LOG_FILE} ${LOG_DIR}/${CUR_MAINT_DATE}
     exit 0
fi


Actually now i want add somemore to this script.... Before this script start i manually generate a LTC*.cvs on windows then run this script to ftp the .cvs file to unixbox.... Now i have decied to put it on cron so it automatically does the work at sheduled time.
On windows i have a maro that converts a .xls file into .cvs... which i run using a .bat and .vbs files... when i double click .bat file it asks me to select the file i want to convert into .cvs file and it converts. it save the converted file in a folder from where the unix script ftp the file.
I to make this manually work automaited i have to either convert the .xls file using unix script or using unix script to trigger .bat file....
I hope you understood what actually i want to do....Please sugesst me

Thanks!
Bhagya
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Not able to call an element from an array in ksh

Hi, I have: # Initialize variables #!/usr/bin/ksh FILENM=$1 INDEX=0 # read filename echo "You are working with the Config file: $FILENM" while read line do echo $line data=$line ((INDEX=INDEX+1)) done <"$FILENM" (3 Replies)
Discussion started by: Marc G
3 Replies

2. Shell Programming and Scripting

Need help with bat file!!!

I need to put/get files from Windows machine to Unix machine and vice-versa. I wrote a text file "ftp1.txt" as below. naga naga06 cd /root/Naga prom off get time.unl bye I wrote another bat file "ftp.bat" as below. ftp -n -s:C:\Users\Naga\Desktop\ftp1.txt IP_ADDRESS but... (2 Replies)
Discussion started by: Naga06
2 Replies

3. Windows & DOS: Issues & Discussions

Executing .bat file

Hi , I have a bat file on windows machine ,I need to excute it from my local unix machine using sambe utility.Is there any comman to execute the .bat file remotely. Using samba utility i can post files to and fro from windows to unix but i don't comman to exute the .bat file. can any one... (2 Replies)
Discussion started by: Raamc
2 Replies

4. Shell Programming and Scripting

HELP. Oracle Call from ksh script

I have searched the forums and couldn't find my specific issue so I figure that I would post on it. I am trying to run a simple sql script that spools to a flat file from a unix script. I have tried to make the call outright from inside of the ksh script as such: sqlplus... (3 Replies)
Discussion started by: BkontheShell718
3 Replies

5. Shell Programming and Scripting

Simple bat file

Hi guys, I need a *.bat to run a ksh file in the shell on Windows NT...nothing more :) How do I do it? I tried with the following but it failed: set INFORMIXDIR=D:\user-applications\informix set PATH=%INFORMIXDIR%;%PATH% D:\user-applications\MKS\mksnt\sh.exe C:\hk_9.2\C3_weekly_auto.ksh... (4 Replies)
Discussion started by: Dird
4 Replies

6. Windows & DOS: Issues & Discussions

Can rsh command be used to call a bat file

I have a .bat file on windows, which converts a .xls file into .csv file and using a ksh script i would usually FTP this .csv file... Now i want to trigger this .bat form my ksh script. can i use rsh command in my FTP to run .bat file on windows and then ftp the generated .csv file...is... (19 Replies)
Discussion started by: bhagya2340
19 Replies

7. Shell Programming and Scripting

Not getting the out value parameter of a DB call in the ksh file

Hi all Im calling a DB procedure as foll sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof var var1 VARCHAR2(200); exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:var1); eof echo $var1 This echo is giving a blank. Also in case the package ODAS_BATCH_JOBS_RETRIEVE is in an un compiled... (2 Replies)
Discussion started by: Sam123
2 Replies

8. Windows & DOS: Issues & Discussions

one question for .bat file

Hi! I'm very sorry for such simple and silly question but I cannot answer it by myself. Can you please help me? In .bat file I should run the C program which is in other directory, and the input configuration file is in this directory too. This dir name is in dirRun variable. The... (3 Replies)
Discussion started by: Anta
3 Replies

9. Windows & DOS: Issues & Discussions

converting ksh scripts--.bat in window's

hi evry one , I did some ksh scripts for file editing in AIX 5.2 ver, issue is while I was trying to run these scripts in windows box as batch files windows is not recognising the awk part of the ksh script,as it is GNU environment, so any one who can help me will be appreciated. this is the... (3 Replies)
Discussion started by: 2.5lt V8
3 Replies

10. UNIX for Advanced & Expert Users

possibility to call subprocesses from ksh ??

Hi!! Is there a possibility to call/start a subproces using ksh ?? Hope that there is somebody to help me. thanks in advance. Corine (3 Replies)
Discussion started by: TheBlueLady
3 Replies
Login or Register to Ask a Question