Results 1 to 8 of 8

Thread: How Do I Create .bat like Scripts?

  1. #1
    Join Date
    Jun 2008
    Beans
    68

    How Do I Create .bat like Scripts?

    How do you create script files in Ubuntu like .bat files in Windows? I want to place a list of commands in a script file and be able to run it as and when required.

  2. #2
    Join Date
    Sep 2007
    Location
    Masschusetts
    Beans
    1,510
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: How Do I Create .bat like Scripts?

    google shell scripting.

    In linux you basically have a choice of ksh, bash, or csh (there are other shells but those are the major ones).
    Registered Linux User: 482377
    MacBook (1,1) - OS X Leopard
    ASUS P5LD2 - Core 2 Duo 3.0GHz - 2GB Corsair RAM - Nvidia 8800GT - Ubuntu 9.04 / Windows 7 Professional

  3. #3
    Join Date
    Jun 2008
    Beans
    199
    Distro
    Ubuntu Development Release

    Re: How Do I Create .bat like Scripts?

    they are .sh files

    run them with a:
    Code:
    ./foo.sh

  4. #4
    Join Date
    Jul 2008
    Location
    Norcross, Ga
    Beans
    55
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How Do I Create .bat like Scripts?

    Rocking Lucid Lynx on AMD Phenom IV 9750 with 6GB DDR2 6400 Ram, Nvidia 9800GTX

  5. #5
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: How Do I Create .bat like Scripts?


  6. #6
    Join Date
    Apr 2005
    Location
    Massachusetts, USA
    Beans
    1,578
    Distro
    Xubuntu 10.10 Maverick Meerkat

    Re: How Do I Create .bat like Scripts?

    Create a new file with the following contents
    Code:
    #!/bin/sh
    
    `command`
    `command`
    `command`
    This is the most basic script with 3 commands..

    Save the file to script.sh and then do
    Code:
    chmod 755 script.sh
    You can now execute it with
    Code:
    ./script.sh
    Bash and other shell language have a fairly rich programming environment, so you can do quite a lot more than MS BATCH files..
    Registered Linux User #446796
    Registered Ubuntu User #13489

  7. #7
    Join Date
    Jul 2008
    Beans
    32
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How Do I Create .bat like Scripts?

    To get started create a file with a name of x.sh (you can replace the x with whatever you want.). Open it in gedit, and for the first line type
    Code:
    #!/bin/bash
    Then you can type in whatever script code you want (pretty much the same thing you type into the terminal. You'll have to read some tutorials if you want to do more complex scripting.

    Save the file, close gedit and right click on the x.sh icon. Go to "Properties" and then to the Permissions tab.
    Check the Execute: box.

    Now you can double click on it and it'll give you a chooice of opening in the terminal.

    All of this process has terminal equivalents, but you can figure those out later.

  8. #8
    Join Date
    Jun 2008
    Beans
    68

    Re: How Do I Create .bat like Scripts?

    Thanks everyone.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •