Re: [SLE] Bat files in Linux

From: John Lalla (john.lalla_at_cox.net)
Date: 04/29/04

  • Next message: Kenneth Schneider: "Re: [SLE] Annoying CD problem"
    Date: Thu, 29 Apr 2004 07:37:22 -0700 (PDT)
    To: reynolds@fastmail.com.au, SuSE Linux Mailing List <suse-linux-e@suse.com>
    
    
    

    On 29 Apr, 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?
    >
    > 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 OFF
    > CLS
    > :LOOP
    > 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%
    > ECHO.
    > :: /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.
    > ECHO.
    > GOTO Loop
    > :ItemA
    > <snip>
    >
    > <end bat file snippet>
    >
    >
    Steve,

    If this kind of customization is what you expect from your computer, you
    have come to the right place. With patience, GNU/Linux will likely
    become your happy home.

    This said, a little reading and experimentation will yield far greater
    results here than in a MS Windows environment. While .bat files provide
    a handy method through which to create quick utilities, particularly for
    configuration and file management purposes, they are limited in their
    ability to interact with other programs that virtually require a GUI
    interface. Not so in an Unix environment, which is essentially all about
    text files calling on one another - with no need for GUI startups. In
    fact, most everything runs better behind the scenes.

    Pontification aside, here's what I recommend. Get some instructional
    material on Shell, Perl and TK. Knowledge in these areas will allow you
    to write just about any command line app you require. They're rather
    intuitive to my mind, and you should be able to learn them quickly.
    Coming from a windows environment, I think you will find TK of
    particular use, as it facilitates a series of apps that will help you
    learn the differences between Windows and Unix methodologies.

    Also, I strongly urge you to read your existing Shell scripts and
    configuration files religiously. Even if you don't quite understand them
    in the beginning, follow their system calls and library loading, etc.,
    as much as you can. Again, Unix/Linux functions through a series of
    interlaced files (largely text). So if you master the art of reading
    these files and start to write your own, you will have total control
    ;) - which is really what we mean by FREE software.

    I realize this might sound like preaching, but I wish someone had
    properly explained the need for this information when I started running
    this very distro some five years ago. I can't tell you how much I
    struggled trying to make early Yast configure everything for me (what a
    mangled mess I would weave in those early days).

    Welcome and cheers!!

    Regards,

    -- 
    John Lalla
    Santa Barbara, CA
    	         .~.	 _
    	         /v\    -o)
    no gates...     /( )\   /\\     running GNU/Linux
      no windows!   ^^^^^  _\_v        free at last!
    "Our capacity for understanding is inversely proportional to how much we
    think we know.  The more I know, the more I know I don't know . . . "
    
    



  • Next message: Kenneth Schneider: "Re: [SLE] Annoying CD problem"

    Relevant Pages

    • Re: Unable to delete
      ... the Command Prompt to help with the typing. ... figured that out from a previous Windows Properties question I ... Since this is a system rebuild, I still need to get a full backup ... does not exist on the main drives. ...
      (microsoft.public.windowsxp.basics)
    • Re: [SLE] Bat files in Linux
      ... > I have a few commands that I would like to run at the command prompt. ... In perl, your script would probably look something like this (quick hack, not ... > ECHO Backup Menu ... > ECHO A. Flash Drive Backup J: ...
      (SuSE)
    • Re: modify incremental_backup
      ... Try the following batch file: ... Run the file from the Command Prompt as it is and check if it ... Remove the word "echo" in line 11 to activate the backup feature. ...
      (microsoft.public.windows.server.scripting)
    • Re: [SLE] Bat files in Linux
      ... > 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. ... > ECHO Backup Menu ... > ECHO A. Flash Drive Backup J: ...
      (SuSE)
    • Re: Backup query
      ... Using windows 2000 on our work computer and we have to backup our files. ... Using the Win 2000 backup program is a nightmare, ... @echo off ...
      (microsoft.public.win2000.general)