Operating System - HP-UX
1834178 Members
2326 Online
110064 Solutions
New Discussion

Re: batch file vs. shell script

 
jane zhang
Regular Advisor

batch file vs. shell script

Hi all,
I wrote a VB program to process some excel data files, those data files are in a specified directory E:\sims, I would like to have a NT batch file whick check the directory, if there are some excel files, it invoke the VB program to process the excel file one by one, it no excel file, do not do anything.
In shell, this is easy to get around by the following code.
#!/bin/sh
INFILE_PATH=/home/janez/sims
for each in ${INFILE_PATH}/*
do
if [ -f $each ]
then
VBprocess $each
rm -f $each
fi
done
Can anybody help me to have a batch file?
Thanks a lot,



8 REPLIES 8
harry d brown jr
Honored Contributor

Re: batch file vs. shell script

jane,

Get perl for NT!

http://www.perl.com/pub/a/language/info/software.html#win32


live free or die
harry
Live Free or Die
Kofi ARTHIABAH
Honored Contributor

Re: batch file vs. shell script

Jane:

You can download cygwin (which provides shell functionality under windows environment - NT etc.) http://www.cygwin.com/
it is a really really good set of programs. check it out.
nothing wrong with me that a few lines of code cannot fix!
Gregory Fruth
Esteemed Contributor

Re: batch file vs. shell script

Sounds like what you really want to do is
run a Bourne/Korn/POSIX shell script on
an NT machine.

Have a look at Cygwin (http://www.cygwin.com).
It provides a nice Unix-like environment under
Windows, including the GNU bash shell. Your
Bourne/Korn/POSIX scripts ought to work fine
under bash. Cygwin almost makes NT
usable :-).
A. Clay Stephenson
Acclaimed Contributor

Re: batch file vs. shell script

If it were me I would download ActivePerl for NT from http://www.activeperl.com. It's free and all you need a loop with a system() call to invoke your VB program within a loop.
If it ain't broke, I can fix that.
Bernie Vande Griend
Respected Contributor

Re: batch file vs. shell script

If the excel files all end in *xls extension:

e:
for /r %i in (\sims\*.xls) do VBProcess %i
del \sims\*.xls

NT shell scripting is not fun. Actually very frustrating for an Unix admin as it is pretty barbaric. If you have a lot of NT scripting to do and don't want to use perl or cygwin, then I'd get a copy of the book: Windows NT Shell Scripting by Tim Hill (Macmillan Technical Publishing) Its a very good reference for NT commands and scripting.
Ye who thinks he has a lot to say, probably shouldn't.
jane zhang
Regular Advisor

Re: batch file vs. shell script

Hi all,
Thank you for the reponses, I decide to switch to perl since I found out we can perl application available and I heard before perl is similiar to unix shell(correct?)
it would be nice of you giving me sample code for this SIMPLE task?
Regards,
Jane
jane zhang
Regular Advisor

Re: batch file vs. shell script

Hi all,
I just figure out the simple solution for my proble.
a simple batch file with the following content is good enough
echo on
for %%i in (e:\sims\*.xls) do sims.exe %%i

especially thank bernie for the hint.
Bernie Vande Griend
Respected Contributor

Re: batch file vs. shell script

Thanks Jane. I forgot to mention that my example was running the command directly from the shell. For some strange Microsoft reason, when commands are in a batch file, it needs an extra % before the variables.
Ye who thinks he has a lot to say, probably shouldn't.