What popular scripting language is closest to BTM?

#1
Hi all;

I've written a number of BTM files at work that are great timesavers for me, but they aren't usable by other team members, and they'd like them. I realize that there's a TCC runtime, but that's not an option, unfortunately. Our environment is C, C++, perl, python, ruby, embedded ruby (I'm not sure how that differs from regular ruby), some bash (Cygwin's in there) and a smattering of PowerShell (which is unpopular).

Does anyone have experience porting .BTM scripts to any other those, or something similar? Any recommendations as to what would be the easiest to port? Which scripting language is closest to Take Command's, in terms of capabilities?

My "problem", so to speak, is that I've been using Take Command since the days of 4DOS in 1989, so I can bang out a quick script that does whatever I need pretty quickly, so I've never actually bothered to learn another scripting language in depth, so I can't do a competitive analysis.

I look at some of the crazy things I see in our environment, where .BAT files are wrappers for Perl scripts that write temp files which are processed by Ruby, and then the output of the Ruby is parsed by the Perl, and then that output goes into a Python script... it's craziness, especially when I can do the same processing in TCC in a single script, faster and more elegantly.

But, I've already lost this argument, and I've been asked to add the functionality to the environment without introducing another scripting language. I can sort of understand that, since we have too many scripting languages already.

A common pattern I have is to have a file with a list of files, and iterate through it using "for line in (@file)", and then process each file in turn. I've not seen anything that's as straightforward as TCC for that.

Any recommendations or comments are welcomed.
 
#2
From ss64

Extracting data from this text file which contains characters and commas (but no spaces or other punctuation):

January,Snowy,02
February,Rainy,15
March,Sunny,25

FOR /F "tokens=1,3 delims=," %%G IN (weather.txt) DO @echo %%G %%H

The tricky part is splitting up each the line into the right tokens, in this case I'm splitting on the comma character ',' this splits the line into 3 chunks of text and we pull out the first and third items with "tokens=1,3"

upload_2017-5-2_17-7-23.png


%%G is declared in the FOR statement and %%H is implicitly declared via the tokens= option.

An alternative way to retrieve the same data would be:
FOR /F "tokens=1,2,3 delims=," %%G IN (weather.txt) DO @echo %%G %%I

Joe
 

samintz

Scott Mintz
May 20, 2008
1,264
11
Solon, OH, USA
#3
Joe,
It's even easier to do this:
Code:
do l in @weather.txt (echo %@word[0,%l] %@word[2,%l])
However, that doesn't address the op's question. To do the above in Python you would do this:
Code:
with open('weather.txt','r') as f:
    for x in f:
        l = x.strip().split(',')
        print l[0], l[2]
 
#4
Joe,
It's even easier to do this:
Code:
do l in @weather.txt (echo %@word[0,%l] %@word[2,%l])
[/code]
I tried that in CMD.EXE, but I received;
Code:
'do' is not recognized as an internal or external command,
operable program or batch file.
As the OP said that he uses .BAT files, it would seem that being able to do it using CMD.EXE is his first preference.

Joe
 
#7
Hey, guys, thanks.

I wouldn't say that using .BAT files is my preference, in fact, far from it. Personally, I'd love to be able to convince the company to buy a site/bulk/whatever licence for TCC and use that, but it's not my call.

Apparently, there's a directive that now we're going all Python, all the time in the future. So now the intra-company fight is whether to use Python 2.x (mature, bazillion modules available, no further development) or Python 3.x (new, fewer modules, more features being developed and added).

I guess I'd better start reading up on Python :-)