ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
it could be argued writing bat(ch) files is not a programming language. in the same argument held to BASH scripting is not programming. per se'
anyways that word 'batch' threw me I have not heard it called batch file in many years, so it did not registered until now, I only recalled bat file and associated it windows, along with the rest of that windows lingo.
Dogpatch's link looks most helpful...some good hints there. Give those a shot and come back with any questions.
Quote:
Originally Posted by BW-userx
I have not heard it called batch file in many years, so it did not registered until now, I only recalled bat file and associated it windows, along with the rest of that windows lingo.
Yes. "batch file" invoked memories of JCL on IBM and WFL on Burroughs in addition to .bat on Windows (which I still have rare occasion to write/maintain)
Edit: I put "windows batch file tutorial" into my favorite search engine and got a page full of guides, basics, and tutorials.
Ok guys I'm sensing some elitism here ....? calm down shhhhhhhhh shhhhhhh (slow hug) shhhhhhh
I'm just asking for simple\common rules (more then one way to skin a cat)
Show me how to use random in batch - I can make menu's but never messed with file path (learn by seeing\doing\talking)
I think bat files falls under programming language ? - Have used Windows for awhile & Batch seemed like a good place to start ?
I'm having fun with it anyway and Linux is for anything computer related ?
"However Wine brings all of it .bat support is one of the few things it does well"
- Using wine to run Notepad++ - The layout is helpful.
Just exploring & tinkering. Would like to see how games are made or need to find something.
I would probably pick any other script/programming language besides a batch file ...
%random% is a pseudorandom number generator that has a range of 0-32767. You can find many examples of how to set a range but typically you use the modulo function. For Example to output a range from 1-10 the equation is:
Code:
set /a num=%random% %%10 +1
echo %num%
random is seeded by the DOS clock which only updates once per second.
I would agree with michaelk. In the Linux/Unix environment you can "write a batch file" in any language – Ruby, Perl, PHP, Python, and more – just by putting #!command_processor_path ("shebang") as the first line. You do not have to limit yourself to the built-in scripting facilities of the bash shell. (Only Dr. Korn's shell ever attempted to have a "real" programming language "built-in.")
And, even in Windows, you now have PowerShell, which, although it's a very different beast, is also significantly more powerful than ".bat files."
Last edited by sundialsvcs; 04-22-2018 at 04:04 PM.
Honestly Linux is new & strange to me - played with CMD\bat awhile back & having fun learning how to make a menu.
Is Programming Algebra, is that the best way to see it ?
"%random% is a pseudorandom number generator that has a range of 0-32767"
That's the problem I'm struggling to talk (begginer) I ment how to make the program pick a random path\selection
C:\%User%\Music\Gaming\
^
How to set random
set /a num=%random% %%10 +1
echo %num%
^
Can you alter the refress ?
The save to text was (> greater than) { C:\ > ipconfig >save name.txt }
"– just by putting #!command_processor_path ("shebang") as the first line. You do not have to limit yourself to the built-in scripting facilities of the bash shell."
It's seems useful to know Windows commands \ self built tools. What language whould you guys recommend (simple,games,menus,apps) ?
trainspotting, "colleague to colleague" I would reply to you ... that you have truly stumbled-into an entirely different (yet, "parallel, all this time ...") ... ...
... ...
... world.
Nothing that you may have learned from "Windows batch files" applies to you equally here ... and vice-versa.
I have not played with batch files in a long time. If you want to go with a scripting language that is cross platform then try Perl, Python, Ruby or PHP.
The shebang is a linux scripting thing and not applicable in Windows.
I would think learning PowerShell would be more useful than batch programming.
Code:
@echo off
setlocal enabledelayedexpansion
set list[0]=path_one
set list[1]=path_two
set list[2]=path_three
set /a num=%random% %%3
echo %num%
call echo !list[%num%]!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.