LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-05-2012, 05:18 AM   #1
karthilin
LQ Newbie
 
Registered: Sep 2012
Location: Chennai
Posts: 13

Rep: Reputation: Disabled
Question how to write a batch file in linux?and what are batch(.bat) file benefits?


I read lot of forums and others but I cant understand clearly.I want clear and short answer.
 
Old 09-05-2012, 05:21 AM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
read about shell scripts instead. that's the appropriate linux talk.
 
Old 09-05-2012, 05:22 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you might want to say please / thank you next time.

you don't use ".bat" files under Linux, that's a DOS convention. the equivalent under Linux would usually be a bash script file, which you can learn to write from reading the bash scripting howto and using the editor of your choice.
 
Old 09-05-2012, 05:33 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
what are batch file benefits?
If we read "batch" (AKA "script") as a generic term covering various operating systems, then a very old truism applies:

"If you don't know why you need it, then you probably don't need it."

Please tell us what problem you are trying to solve---e.g. do you need to write (or modify) a script on an existing system?
 
Old 09-05-2012, 05:34 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,254

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
See these links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 09-05-2012, 05:35 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Quote:
Originally Posted by pixellany View Post
Please tell us what problem you are trying to solve---e.g. do you need to write (or modify) a script on an existing system?
A need to get homework in on time?
 
Old 10-15-2012, 09:51 AM   #7
karthilin
LQ Newbie
 
Registered: Sep 2012
Location: Chennai
Posts: 13

Original Poster
Rep: Reputation: Disabled
Wink Thank You!

Thanks For all
 
Old 10-15-2012, 02:40 PM   #8
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,617

Rep: Reputation: 442Reputation: 442Reputation: 442Reputation: 442Reputation: 442
Quote:
I want clear and short answer.
NO .bat in Unix.
NO .bat in Gnu.

In your mind are but windows without doors.
 
Old 10-15-2012, 03:10 PM   #9
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,657
Blog Entries: 10

Rep: Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075Reputation: 2075
Quote:
Originally Posted by karthinila View Post
I read lot of forums and others but I cant understand clearly.I want clear and short answer.
Short Answer to your problem is there isn't one.

http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.gnu.org/software/bash/man...ode/index.html
http://www.grymoire.com/Unix/Sh.html
http://tldp.org/LDP/abs/abs-guide.pdf
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
http://rute.2038bug.com/index.html.gz

You don't write "batch files" in Linux.
(for the sake of simplicity here), they are called shell scripts, or perhaps just scripts and have a usual .sh extension.

.bat files cannot run in linux (except in Wine?)
Linux shell scripts can be run in cygwin on Windows, but not as "batch files".

They mostly do the same thing, process and accept supplied commands to the host's command interpreter.
Both environments process their respective script.sh or file.bat one line at a time.

Both Windows' batch files and Linux's shell scripts can be manipulated to behave in the desired manner, although the commands to achieve that 'desired manner' may differ from Linux to Windows and vice versa.

Example.
a Windows batch file that has "cls" to clear screen ...would be in a Linux shell script as "clear"

It is my advice and belief that where you read is as important as what you read.
Start with http://rute.2038bug.com/index.html.gz

Have a Great Day!

Last edited by Habitual; 10-15-2012 at 03:11 PM.
 
1 members found this post helpful.
  


Reply


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
Can I write batch file rajiv.birari Linux - Newbie 10 10-16-2008 07:05 AM
How to convert a batch file(.bat) to script file(.sh) manas_sem Programming 4 06-28-2007 01:10 PM
how to write a batch file to make a program run during boot up in windows??? b0nd Programming 7 09-04-2006 07:16 AM
How do I write a script (batch file)?? cvzyl Linux - Software 4 07-30-2006 10:11 AM


All times are GMT -5. The time now is 10:58 AM.

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