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
# 8  
Old 01-09-2009
To tell you the truth I was worried that you will write such an answer...

1) Do not use cron for such purposes. You might set a task in cron (task that would execute every minute)... But this is not the purpose of cron. Use it to execute some periodic scripts like cleanup that is performed once a day.
Of course you can use cron like you do - but there are many reasons why you shouldn't... I'll give you only one here:
Checking your mail manually every hour by going to the post office is a bad idea - instead there is a postman that would bring it to you when a new mail is present.
In the software world: you should not execute this code every minute. You should use some event based mechanism instead.

2) Different boxes => you cannot(*) execute an application on the remote host
(*) - in fact you can but you shouldn't

3) I would suggest a simple application (JAVA, C#, whatever) that is running as a service (get a service template from the web) and is listening on some network port. When your *.vbs, *.exe, *.whatever should be started - you just send a notification to the windows box (which acts as a server).
Example solution (probably not the best but simple one):
Some web server with server-side scripts support (like python... or php... or perl). The script is executing the .vbs file. You don't need bat file in that case.
According to my tiny humble experience you will use perl scripts or something similar (personally I do not like perl because it is way too easy to make the code unmaintainable).
# 9  
Old 01-09-2009
Thanks... You mean to say these no one way i can do what i actually have to do... I dont know perl and i dont think its there on my unix box...
How can i see if perl is there on my Unix box,... i mean how can i know i can use,...
If i can use perl on my unix box can you say me what commands i need to use to trigger my .vbs file so it does it work...

Thanks
# 10  
Old 01-09-2009
You do not understand me.
I'm telling that you shouldn't do the thing that you wanted to do (like you should not shoot in your head... but you have a free will and you can do whatever you like).

In the example (crappy, terrible, dishonored and worthless) solution that I gave:
1. Windows box is running a web service
2. Unix box is running anything (can be shell script + wget).

Example web service is some web client with perl support. You can grab activeperl for windows. Web server of your choice.
perl script would be simple: something like
Code:
#!perl -w
system('start command.vbs');

(Note that I do not like perl and syntax of SYSTEM is probably different)
Shell script would call something like "wget my.windows.box.com/hack_me_cause_this_software_is_easy_to_hack.pl"
# 11  
Old 01-12-2009
Thanks a lot... i tried to see if my system have perl and found that i dont have anyways i want a suggestion. can i use cron to trigger a .bat file

EG: 30 14 * * 4 \\pbhp-oa-001\Temp bhagya.bat
the bat file is bhagya.bat, at \\pbhp-oa-001\Temp (on windows server) and must on every thursday at 14:30PM

can i do this?? can i trigger a bat file using cron... please suggest me

Thanks
# 12  
Old 01-12-2009
It is a little difficult for me to understand what you are writing - sorry for telling this but you should work more on your English (I know that mine is not perfect either).
To execute *.bat, *.vbs, *.exe, or any other file on windows box you need to execute it on the windows box, not unix box.
You can use CRON - but you should not.
Seems like you could use windows "at" command (but again: that is not the correct solution). You can install cygwin as well and try cron from there (again: that is incorrect approach).

My advice: you need to read about event driven software and its pros over things like cron. Or at least about multitasking. Never write code that works in an endless loop with "delay" in every loop execution.
# 13  
Old 01-13-2009
I am sorry if i dint explain you properly,.... Actually you know that a .bat file shouldnt be called from cron ( though its possible in some way which i am tring to firgure out) and from you i came to know that if i do there will be a security issue... but my team lead doesnt know that....after i say her she doesnt care,... she just want it to work and by this thursday...
First of all i dont know how to do it, next i have no other way to do and i dont fine any kind of information on how to do it...
I just want to schedule it using cron or use a Ksh script to run it....as i dont want to lose my job in a market like this. so try to help me plzzz

Thanks
# 14  
Old 01-13-2009
Yes you can run a .BAT from Cygwin cron. It's a dumb solution but do-able. First of all you have to set up the Cygwin cron. Do a web search or read the Cygwin manual for how to do that. Then you need to create the correct cron entry to call your .BAT file on the required schedule. Then you probably need to modify your .BAT file to ensure that it has the right paths, etc. so that it can run successfully under cron.
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