Mailinglist Archive: opensuse (2271 mails)

< Previous Next >
Re: [SLE] Bat files in Linux
  • From: "Jerome R. Westrick" <jerry@xxxxxxxxxxxx>
  • Date: Thu, 29 Apr 2004 18:10:54 +0200
  • Message-id: <1083255053.5660.5.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
On Thu, 2004-04-29 at 15:51, Steve Reynolds wrote:
> I have a few commands that I would like to run at the command prompt.
> In Windows I do this with a bat file that looks like the sample below. How do
> I do a similar thing with Linux?

Same Bat time, Same Bat Channel, Same Bat files....

Seriously, now...
you do thoose in a "shell". Unlike windows, there are lots of them
around. Additinally, you can program the commands in one of the many
"Interpreters" around (perl, python, ruby) come to mind.... and execute

I know better than to suggest one over the other, as that is sure to
start of a long thread with a bunch of people touting thier

hope this helped....
At least so you can make your next question....


> For those not familiar with windows bat files the snippet below presents the
> user with a menu at the command prompt.
> In windows I have a shortcut to a text file called backup.bat, when I double
> click that shortcut I launch a DOS window with the menu below already loaded
> for the user. I would like to do a similar thing with Linux.
> <begin bat file snippet>
> ECHO Backup Menu
> ECHO ===========
> ECHO A. Flash Drive Backup J:
> ECHO B. Main Backup to CD
> ECHO C. Main Backup to F Drive
> REM ECHO D. Archive Backup
> ECHO E. Allofmp3 Backup to CD
> ECHO F. Flash Drive Backup I:
> REM ECHO G. REVERSE Flash Drive Backup From Linux:
> ECHO H. Photos Backup to iPod
> ECHO Q. Quit
> :: SET /P prompts for input and sets the variable
> :: to whatever the user types
> SET Choice=
> SET /P Choice=Type the letter and press Enter:
> :: The syntax in the next line extracts the substring
> :: starting at 0 (the beginning) and 1 character long
> IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
> :: /I makes the IF comparison case-insensitive
> IF /I '%Choice%'=='A' GOTO ItemA
> IF /I '%Choice%'=='B' GOTO ItemB
> IF /I '%Choice%'=='C' GOTO ItemC
> IF /I '%Choice%'=='D' GOTO ItemD
> IF /I '%Choice%'=='E' GOTO ItemE
> IF /I '%Choice%'=='F' GOTO ItemF
> IF /I '%Choice%'=='G' GOTO ItemG
> IF /I '%Choice%'=='H' GOTO ItemH
> IF /I '%Choice%'=='Q' GOTO End
> ECHO "%Choice%" is not valid. Please try again.
> GOTO Loop
> :ItemA
> <snip>
> <end bat file snippet>

< Previous Next >