Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-03-2007, 01:06 AM   #1
LQ Newbie
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
Question Does linux run bat files like DOS

Just getting started with Linux. Does Linux have a routine/program to run batch files like DOS does with bat files?

My question pertains to making the menu.lst boot to XP first and second to Ubuntu... I got it but I would think a simple two line bat to open it as writable then do the cut and paste for the boot sequence. Finally a one line bat to change menu.lst back to read only.

The reason I am asking is that most patches I see must be run in terminal mode. If these patches could be copy/cut and paste into a (bat) file and run it would be easier than running in terminal mode and doing all that typing and correcting my mistakes when looking back and forth from the information I am typing.
Old 07-03-2007, 01:36 AM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
The *nix equivalent of bat files is shell scripts. In Linux, the shell is usually bash, so those would be bash scripts.

Like bat files, bash scripts mimic closely what you'd type on a command line. For an intro to bash, google this:

bash tutorial
Please do not read what's in the following box:

This is obviously an oldie.

Q: What do you get when you cross Lee Iacocca and a vampire?

A: autoexec.bat
Hope this helps. The first part of this, anyway.
Old 07-03-2007, 03:59 AM   #3
Registered: Apr 2005
Location: Timaru, New Zealand
Distribution: Manjaro
Posts: 105

Rep: Reputation: 15
If you are only just getting started with Linux, you might be best, at this early stage, not to concentrate on Shell Scripts until you get a bit of a feel for the whole Linux thing. A particularly good book, that will bring you into shell scripting in a logical and timely manner - by giving you the preliminary background you'll need first - is Paul Sheer's "Rute Users Tutorial and Exposition" For a free electronic copy:
When you have studied this excellent book (don't be put off by its age by the way) I suggest you work through a good few wee exercises, as suggested by the author, before trying to do your own little exercise - to get a bit of a feel for the idea of writing and executing scripts. From my experience they are not exactly like DOS bat files because relative to DOS, there are a huge number of very precise and powerful variations in what you can do. Good hunting!

Old 07-03-2007, 10:22 AM   #4
Senior Member
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 9 Stretch
Posts: 2,349
Blog Entries: 8

Rep: Reputation: 383Reputation: 383Reputation: 383Reputation: 383
It's perfectly possible to write small scripts to mess around with menu.lst. Rather than manipulate the contents of the file, the easiest thing is to just have a couple versions of the file and copy the desired version to menu.lst. For example, you could have one version which defaults to Windows and another version which defaults to Linux.

However, no bash script will run before Linux is booted up. Grub is a very small bootloader utility program which does NOT include bash. If you want some fancy bootloader logic, then you'll need to customize something more sophisticated than just grub. This isn't really a newbie project.

Anyway, menu.lst is writeable by default, by the root superuser. There's no need to make it read-only.

Personally, I always use the "default saved" option in menu.lst when dual booting. That way, in defaults to booting up the OS which was booted up last time.
Old 07-04-2007, 01:03 AM   #5
LQ Newbie
Registered: Jun 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Hey thanks to all three of you..... what a pleasure to receive such simple but knowledgeable feedback.

I have already started the Rute User's Tutorial and Exposition before I am responding.

Thanks again.

I'll be back
Old 07-04-2007, 01:42 AM   #6
Registered: Nov 2006
Location: Bangalore,New delhi
Distribution: RHEL5, Kubuntu, Mandriva 2008
Posts: 69

Rep: Reputation: 15
Shell scripts are analogous to DOS batch (.bat) files. That is, shell scripts are simply text files (created with any text editor) that contain a series of commands. These commands can be Linux OS commands, commands that run programs, commands that "call" other scripts, or any combination of these. That way you just execute the script every time you want to accomplish a task or process rather than typing in all the commands by hand every time.
(If you're experienced with DOS, you may want to check out for a comparison of DOS-to-Linux batch file statements and shell commands.)
As such, the various shells in Linux are not only a user interfaces but kind of like programming languages as well. The Korn shell is considered the best shell for programming on UNIX systems and the Linux Bash shell incorporates many of the Korn shell's functionality.
Old 07-05-2007, 12:47 PM   #7
LQ Newbie
Registered: Jun 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for the feedback.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run DOS EXE file in Debian Linux RMLinux Linux - Newbie 4 08-17-2006 02:25 PM
Linux equivalent of bat files anjanesh Linux - Newbie 19 12-30-2005 01:15 PM
how to run the *.bat file ztdep Linux - Software 8 07-19-2005 05:36 PM
.bat files on Linux? dave1.1 Linux - Newbie 5 10-21-2004 08:15 PM
"batch files" in red hat, similar to .bat files in dos shycalais Linux - Newbie 2 10-12-2003 09:34 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration