|
Scripting is programming the shell, with complex logic (i.e. conditions, loops, etc).
Quick automation to me means executing a simple sequence of commands with their parameters, with only a very small amount of logic (i.e. setting relative paths, file names and in some cases checking some return value). It's a quick macro, a shortcut to avoid typing dozens of characters.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
It's odd how definitions tend to change with time.
When I studied automation many many years ago, scripting was one of the tools available to achieve the task... today it seems to be a cron job.
|
|
|
|
|
I still use them, they are just so easy to work with compared to the "wonderful" Powershell.
|
|
|
|
|
And me - if you're going to use the advanced PS stuff you might as well write a proper compiled program
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
I have actually found a few occasions when a Powershell script of three or four lines did what in C would have needed at least 30 to 50 lines. The main problem I have with Powershell is learning it properly.
|
|
|
|
|
And then you run into things like PowerShell is disabled because users can't be trusted not to destroy the systems with it.
|
|
|
|
|
lol, this is in fact an issue. Trying to explain to the IT department that we MUST have local admin access.
We've finally developed a trained set of IT professionals that understand we accept the big boy warranty.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
How should I compile without batch files ?
I like them. Back in the years, I even made quite powerful things with batches ( against all best practices of coding, of course. Batch is organized chaos).
|
|
|
|
|
Batch files rule!!
I still depend upon them and have done for well over 30 years. How many other technologies "just work" for over three decades?
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
I love the answers to this.
For everything someone hates (except maybe linq)
there are at least a person or 15 that loves it.
I personally use BAT files all the time. Like someone said. Perfect for automation of something simple, IE copy file1 to file location2 at this time everyday.
I also use Powershell a ton. It works it is difficult to learn and get accustomed to. But it is powerful.
When in Linux I use your good old shell scripts. Those are awesome. But I am stuck with bat and winders powershell at work.
Also, love that comment about powershell security for some people to keep them from shooting themselves in the foot. HAHAHAHA
To err is human to really elephant it up you need a computer
|
|
|
|
|
Bat/cmd files are and always will be the easiest way to automate the command line. Many times, it's even easier to use a bat file in task scheduler than it is to try and get the commands working with task scheduler, especially if there are multiple commands or maybe other considerations. The right tool for the job, as always.
As far as in depth scripting, everyone knows the best tool is vbscript. When that fails, bust out the Visual Studio...or sometimes powershell once in a blue moon.
|
|
|
|
|
It appears it was Tim Paterson and he's not dead yet https://www.youtube.com/watch?v=uBxMPqxJGqI. So, you'll have to wait.
My company has been using some .bat files for certain things and they still work decades later, never needing an update or change.
|
|
|
|
|
I found that the two big problems with .bat files ( actually the command interpreter ) _wasn't_ it's weakness, but that the bright eyes at Microsoft:
1, typically didn't have commands return anything ( the stupid elephanting "void main(void)" mentality before that plague started ), and
2. edlin can't do search and replace when script driven. ( As I remember, it can't do _anything_ useful without using the "F" keys. )
( I had a Regulus box years back, it built the apropos database ( overnight ) by reading the man directory and chaining shell scripts, I think the only thing it did other than build scripts with ed that dos couldn't by itself was use "roll" to pick successive keywords)
|
|
|
|
|
Just to clarify the point, modern windows OSs don't run MS-DOS.
Early versions of windows and the 9x line ran on top of MS-DOS so launching a command prompt would actually just expose the MS-DOS command interrupter running underneath windows.
The Windows NT line, which XP, Vista, 7, 8 and 10 are a part of, was developed separately from MS-DOS and doesn't contain the MS-DOS command interrupter. Instead it has a program called cmd.exe which supports a similar set of commands but is very much distinct from MS-DOS.
So Windows bat/cmd files still exist and are used but they aren't MS-DOS bat files.
|
|
|
|
|
Kyle Brown wrote: So Windows bat/cmd files still exist and are used but they aren't MS-DOS bat files. Obviously, they are still .bat files, though!
Like a C++ or C# file: It is still a set of instructions to be interpreted by some compiler and runtime system. Even if one environment retires, the semantics of the instructions remain for interpretation in some other environment.
You could easily write a .bat file interpreter for a linux environment, like you can write interpreters for bash or sh scripts in a Windows environment. The underlaying OS and runtime for the interpreter is not essential.
(Except, of course, if the interpreter insists on a non-conforming interpretation of the actual environment. Such as insisting on environment symbols being case sensitive, when the environment defines them as not case sensitive. But this is a question of the interpreter honoring conventions of its environment, not of the execution platform of the interpreter.)
|
|
|
|
|
As for me, if the task is too complicated for a simple BAT file, I write it in C#. For me (not speaking for anyone else), I have not found a good use for me to use PowerShell, and I have avoided the UNIX-like OSs (like Linux) as much as possible since the early 90s.
|
|
|
|
|
What we need is a library built upon a framework with designers, design patterns, logging, a UI and SASS implementation so that a few lines of code can be turned into the nightmare that is modern web development.
|
|
|
|
|
Charlie:
I see I am falling into the next thread (Sure sign I should retire -- I know what a Wang and an AS/400 are). Batch files predate MS-DOS. They were how things were done on RT-11 and RSX-11 on PDP-11 computers. Many of the C and Unix and early PC operating system guys all started on PDP-11s (circa 1975) when they were in school. So the guy you are looking for probably is very long dead and buried near Boston.
I suppose it is interesting that it is still possible to write really horrible batch files to run in a command window. Just recently did an update on a set of TeraTerm command files. Interesting, but not something I would do by choice!
The guy who *really* deserves our hatred is the guy who created all the macros for MASM and early versions of Microsoft C. If you ever had a bug caused by one of those, you could spend a career just trying to unroll all of the macros
|
|
|
|
|
lol, I actually know what those are, toured a factory where Wang minis were built and have developed drivers on PDP-11s.
my biggest beef with BAT files is that if you properly format "your code" - like add a space when assigning a variable, the assignment fails.
I'm ranting I know. I have to build for Windows Xp, Windows 10, multiple build tools, and some day migrate it to a build engine.
The BAT files are portable, but I can see obvious support issues.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I was part of a (yes, virtual) gathering of IT people from various backgrounds and specialties. After a while, things boiled down to everyone sharing some of their strangest experiences with non-it clients and coworkers. Everyone was laughing and having a great time. My turn came around, and I started sharing a story about a project I was involved with where the company was upgrading from and old Wang system to AS/400. Everyone suddenly went quiet, and I noticed that most of the people with cameras were sporting blank expressions. After a couple of seconds, one of the younger guys asked, "What is a Wang? Is that a slang term? And how is an AS/400 considered an upgrade?" Everyone was nodding their agreement.
... That was when I realized that I must be the oldest one there.
Maybe I should have gone with the Banyan Vines story instead.
Money makes the world go round ... but documentation moves the money.
|
|
|
|
|
Oh man, I loved working on Wangs, the first company I worked for ported their accounting software from the PDP machines. They were a solid machine, I don't recall (but its 35 years ago) having any issues with them.
Pity they went bust.
// TODO: Insert something here Top ten reasons why I'm lazy
1.
|
|
|
|
|
Could have mentioned the old Kaypro luggable as an early laptop(ish).
|
|
|
|
|
Come and gone, fer sure. I remember doing custom hardware/software for the Kaypros for the oilfield industry on the North Slope, easiest custom hardware platform I had for a while.
A human being should be able to change a diaper, plan an invasion, butcher a hog, navigate a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects! - Lazarus Long
|
|
|
|
|
I was working on a job in Mexico and my boss made me take a Kaypro, knowing that I wouldn't use it. I remember lugging it through the airports and to/from hotel. Them damn things are heavy!
|
|
|
|
|
My first "portable" computer consisted of me drilling the case of my PC, and mounting a trunk handle to the top, and an eye loop,to the back. I could then put a strap on it, and carry it on the bus between home and the office. Yes, it earned me lots of stares, but it worked well. I even took it to school a couple of times.
Money makes the world go round ... but documentation moves the money.
|
|
|
|
|