Why not Batch files??

C

Chris L.

Dear All-
This post is in regard to a certain article I recently read on batch
files. I currently use the Perl system() function to call a batch files
when I need to run other applications from my perl program:

system ("CALL", $batch_file1");

....and it works great. However, the article was explaining how batch
files were almost extinct in programming. I am wondering if this is
accurate or not. That is, should I be utilizing something else to
automate Windows system calls? Are batch files a thing of the past? If
so, what should I be focusing my attention on to replace them?

Thank you for your time and expertise.
Chris
 
X

xhoster

Chris L. said:
Dear All-
This post is in regard to a certain article I recently read on batch
files. I currently use the Perl system() function to call a batch files
when I need to run other applications from my perl program:

system ("CALL", $batch_file1");

...and it works great.

It doesn't even compile.
However, the article was explaining how batch
files were almost extinct in programming. I am wondering if this is
accurate or not. That is, should I be utilizing something else to
automate Windows system calls? Are batch files a thing of the past?

For me they sure are. YMMV.
If
so, what should I be focusing my attention on to replace them?

Hmmm. How about that silly old language called Perl? I mean, you are
posting to a Perl group, so it does seem like you should already have an
inkling that Perl exists, no?

Xho
 
P

Paul Lalli

Chris said:
This post is in regard to a certain article I recently read on batch files.

Then it would seem that the author of the article or the site on which
you found the article would be an appropriate place for follow ups, no?
However, the article was explaining how batch
files were almost extinct in programming. I am wondering if this is
accurate or not. That is, should I be utilizing something else to
automate Windows system calls? Are batch files a thing of the past? If
so, what should I be focusing my attention on to replace them?

I'm very confused as to what your Perl question is.

Paul Lalli
 
R

raymondnatt

Are batch files a thing of the past?

It is surely used less and less from what I can see. You can use Perl
or 3rd party automation software. I suggest try 3rd party automation
software. Good once are not FREE but they provide a better way to write
and edit scripts.

We use this program called Automation Anywhere. There are many others
out there as well. Google search can get you that.

ray
 
V

Veli-Pekka Tätilä

Chris said:
currently use the Perl system() function to call a batch files when I need
to run other applications from my perl
was explaining how batch files were almost extinct in programming. I am
wondering if this is
accurate or not.
Hmm I don't think this is a real Perl question, you might want to try some
batch forum in stead. I'll reply nevertheless but flag this topic as OT for
convenience.

Well I'd been using batch files loads for quick hacks before I learned that
Perl is as good as it is. Now I do all of my previous batching in Perl and
it's been a real time saver.

But before I got into PErl big time I did some experimentation and have
written a tutorial about Batch files and the NT/2k/XP command extensions.
Here it is:

http://www.student.oulu.fi/~vtatila/batch_tutorial.html

[Oh yes, and I'm going to write a basic Perl tutorial, as soon as I have the
time and feel I'm proficient enough in the language.]

Briefly put, modern batch files are still about as expressive as the late
70s basics like tinybasic and have equivalents to let, if, print and goto.
Plus some Windows specific stuff thrown in, such as interfacing to Win32
console apps and some elementary file parsing constructs, but that's about
it. Still I think the code is very ugly and doesn't support structured
programming or proper data structures at all.

I'm glad to hear MS is going to finally revamp their shell.
utilizing something else to automate Windows system calls?
You mean calling executables or batch files, I suppose. The term systemcall
has a very specific meaning and basically comes down to calling lowlevel OS
(kernel) services rather than using the system command in Perl. And in
Windows the system calls are actually abstracted behind a higher level API
called Win32. I just view this as just another level of indirection, that is
they can change the underlying calls as much as they see fit, as long as the
Win32 implementation stays the same to keep legacy apps happy.
 
J

Juha Laiho

Chris L. said:
This post is in regard to a certain article I recently read on batch
files. I currently use the Perl system() function to call a batch files
when I need to run other applications from my perl program:

system ("CALL", $batch_file1");

...and it works great.

Ok, questions, to hopefully clarify your situation;

1:
Do you write these batch files yourself, or are they written by the
provider of the called application (supposing you're not developing
also the other application)?

If these batch files are provided by a third party and are intended to
be the primary means to launch the application, then I would consider
them as the published interface to launch that application, and thus
would use them.

If, however you write these batch files yourself, read on.

2:
Are these batch files you write intended to be called from clients
using a multitude of technologies (f.ex. from non-perl scripts,
directly from desktop, ...)?

If so, they provide a valid "tehcnology-neutral interface", and
serve their purpose.

If, however, your perl script (or a set of your perl scripts) are
the only clients calling these batch files, then the question becomes:

Do these batch files do something you couldn't do within perl?
Apparently, in the end, they launch a program. That you can do
from within perl. The issue is, what is done before that? Would
that be doable (with reasonable effort) within perl? If so, then
I'd get rid of the batch file and re-write the functionality in
perl -- one less technology to maintain.

If there are multiple perl scripts needing this functionality, then
it'd make sense to write it as a module (so, creating a module to
wrap the application launch logic), and use that module from
all the client applications.
 
L

l v

Chris said:
Dear All-
This post is in regard to a certain article I recently read on batch
files. I currently use the Perl system() function to call a batch files
when I need to run other applications from my perl program:

system ("CALL", $batch_file1");

...and it works great. However, the article was explaining how batch
files were almost extinct in programming. I am wondering if this is
accurate or not. That is, should I be utilizing something else to
automate Windows system calls? Are batch files a thing of the past? If
so, what should I be focusing my attention on to replace them?

Thank you for your time and expertise.
Chris

Lately I use batch files less because of Perl's ease. While I could
trick a batch file to do what I wanted (at times), Perl was a natural
fit. I can also say the same with unix shell scripts. I found I was
echoing things to awk more than I wanted. Why not just do the whole
thing in Perl. However, there are times I'll use a batch file over
Perl and vice-a-versa. For example, I have some Perl scripts which do
several tasks to my jpeg images using ImageMagick (i.e. creating a
standard size thumbnail.). I coded the Perl script to process one
file, passed in as and command line argument. It's great for the times
I need to do a few jpegs. However, if I need to process an entire
directory of jpegs, I use a batch file which uses *dos*'s for command
which executes the perl script i.e.
for %%F in (*.jpg) do d:/batch/mkThumb.bat %%F "%%~nF.thumb%%~xF"
for %%F in (*.jpg) do perl C:/Perl/source/imagemagick/addkey.pl %%F

IOW, don't give up using something because of something you read off
the web (usenet included) if you have a use for it and it is doing
exactly what you want it to do.
 
R

robic0

Lately I use batch files less because of Perl's ease. While I could
trick a batch file to do what I wanted (at times), Perl was a natural
fit. I can also say the same with unix shell scripts. I found I was
echoing things to awk more than I wanted. Why not just do the whole
thing in Perl. However, there are times I'll use a batch file over
Perl and vice-a-versa. For example, I have some Perl scripts which do
several tasks to my jpeg images using ImageMagick (i.e. creating a
standard size thumbnail.). I coded the Perl script to process one
file, passed in as and command line argument. It's great for the times
I need to do a few jpegs. However, if I need to process an entire
directory of jpegs, I use a batch file which uses *dos*'s for command
which executes the perl script i.e.
for %%F in (*.jpg) do d:/batch/mkThumb.bat %%F "%%~nF.thumb%%~xF"
for %%F in (*.jpg) do perl C:/Perl/source/imagemagick/addkey.pl %%F

IOW, don't give up using something because of something you read off
the web (usenet included) if you have a use for it and it is doing
exactly what you want it to do.

Given this is a general Perl group, maybe you should find Unix groups with a Perl slant
for your fuckin blow hard garbage ...
 
R

robic0

What he wrote, of course, had nothing to do with Unix.

Sinan

Uh huh...
for %%F in (*.jpg) do d:/batch/mkThumb.bat %%F "%%~nF.thumb%%~xF"
for %%F in (*.jpg) do perl C:/Perl/source/imagemagick/addkey.pl %%F

-robic0-
 
1

1usa

robic0 said:
Uh huh...
for %%F in (*.jpg) do d:/batch/mkThumb.bat %%F "%%~nF.thumb%%~xF"
for %%F in (*.jpg) do perl C:/Perl/source/imagemagick/addkey.pl %%F

Let me paraphrase ...

What he wrote, of course, had nothing to do with Unix.

Sinan
 
R

robic0

Let me paraphrase ...

What he wrote, of course, had nothing to do with Unix.

Sinan

Keep trying, its not *nix, its just not...
for %%F in (*.jpg) do d:/batch/mkThumb.bat %%F "%%~nF.thumb%%~xF"
for %%F in (*.jpg) do perl C:/Perl/source/imagemagick/addkey.pl %%F

-robic0-
 
1

1usa

robic0 said:
Keep trying, its not *nix, its just not...
for %%F in (*.jpg) do d:/batch/mkThumb.bat %%F "%%~nF.thumb%%~xF"
for %%F in (*.jpg) do perl C:/Perl/source/imagemagick/addkey.pl %%F

-robic0-

You know, we could keep doing this forever (after all, I am posting
from GG, so rules apply ;-), but it has already ceased to be amusing
for anyone with an IQ above room temperature.

The two lines above are from a batch file. They should work with
anything from command.com in DOS v5 to the XP cmd.exe shell.

None of this is really relevant, of course.

The for loop in the XP cmd.exe shell has many more options. You can
read about them by typing

C:\> for /?

on the command line.

Roger?

Sinan
 
R

robic0

Lately I use batch files less because of Perl's ease.

Lets see here, you think Perl is better than 'batch' files.
So how does Perl compare to batch files? I think
Larry Wall would like to know his creation is 'just this side
better than, er ahh, batch files'...

-robic0-
 
R

robic0

You know, we could keep doing this forever (after all, I am posting
from GG, so rules apply ;-), but it has already ceased to be amusing
for anyone with an IQ above room temperature.

The two lines above are from a batch file. They should work with
anything from command.com in DOS v5 to the XP cmd.exe shell.

None of this is really relevant, of course.

The for loop in the XP cmd.exe shell has many more options. You can
read about them by typing

C:\> for /?

on the command line.

Roger?

Sinan

Yup, roger. I know the cmd shell. But I'm sure you don't. Its a complicated
beast! As to the game, well maybe we get to know each other. I stand on what I
post. I correct my mistakes (if) and timely, and I respect others who follow
suite!

-robic0-
 
R

robic0

Yup, roger. I know the cmd shell. But I'm sure you don't. Its a complicated
beast! As to the game, well maybe we get to know each other. I stand on what I
post. I correct my mistakes (if) and timely, and I respect others who follow
suite!

-robic0-

Since in the far past I've had to use the NT shell (as you call it) to build
drivers and installs. The phrasing 2 lines above is clearly meant for Unix.
I don't know wht your, or is 'GG' means but thems the facts.
The NT shell is one of the most complicated shells ever created. 'It' has nothing
to do with Unix, except by the accidental, unknowing verbage overlapp...

Let this dog lie or it will bite ya!

-robic0-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top