Re: Bash Script (WAS:Re: Suse 9.3 on a desktop replacement)

From: Kevin Nathan (knathan_at_project54.com)
Date: 08/20/05


Date: Fri, 19 Aug 2005 22:29:05 -0700

On Fri, 19 Aug 2005 21:26:48 -0700
PerfectReign <theperfectreign@yahoo.com> wrote:

> Well...
>
> I created a batch file called, startup.bat.
>

Yuk! 'batch file'? '.bat'? While perfectly fine, far too many bad
memories conjured up by that name choice; use 'script' and '.sh' or no
extension . . . ;-) I was quite adept at that crippled system and, over
the course of several years, had perfected a batch file system that
enabled me to edit, compile, link and perform other programming tasks
on any of my projects in MS-DOS, NDOS and Real/32 with a minimum of
typed commands -- it spanned 30+ batch files and close to 2000 lines.
While it worked, and worked well, I can do virtually the same thing in
Linux just by using emacs or a few, small scripts . . . :-)

> -----------------------------------------------
> su --login root -c 'echo Starting apache2 ; echo Starting mysql'
>
> /etc/init.d/Apache2 start
> /etc/init.d/MySQL start
> -----------------------------------------------
>

First of all, are you *sure* that '/etc/init.d/Apache2' and
'/etc/init.d/MySQL' exist in that dir with that exact capitalization?
If so, then you need to fix the script above. I was apparently not
clear enough about the 'echo...' commands just being place holders for
demo purposes. Try this instead:

su --login root -c '/etc/init.d/Apache2 start ; /etc/init.d/MySQL start'

These commands have to all be on the same line; putting them *after*
the line containing the 'su...' effectively keeps them from working. If
you really want user feedback in the form of echo commands (and
possibly other things), then create a script containing all you want to
do and substitute it for the above line like so:

    su --login root -c /home/username/bin/nameOfBigScript

assuming 'nameOfBigScript looks something like this:

   #!/bin/bash
   echo Starting apache2
   /etc/init.d/Apache2 start
   echo Starting mysql
   /etc/init.d/MySQL start

and you've done a:

   chmod a+x /home/username/bin/nameOfBigScript

> I got:
>
> kai@linux:~/bin> sh startup.bat
> startup.bat: line 1: -----------------------------------------------:
> command not found

I'm pretty sure I said to *not* include the dashed lines . . . :-D

-- 
Kevin Nathan (Arizona, USA)  
Linux Potpourri and a.o.l.s. FAQ -- http://www.project54.com/linux/
Open standards. Open source. Open minds. 
The command line is the front line.
Linux 2.6.8-24.17-default
  9:54pm  up 10 days  2:45,  14 users,  load average: 0.11, 0.23, 0.16


Relevant Pages

  • Re: Copying files to another drive
    ... A batch file is a plain text file; you can create it with notepad or any text editor. ... It may include any of the W2k commands; see Help/ Contents/ Reference/ MSDOS Commands. ... I have 3 drives, C:\, D:\ & ... @echo off ...
    (microsoft.public.win2000.general)
  • Re: what kind of scripting is this ?
    ... echo Good morning %name% ... Batch files have nothing in common with VB Scripting. ... is far more powerful than batch file programming. ... A batch file consists of a collection of commands ...
    (microsoft.public.scripting.vbscript)
  • Re: Environmental Variables batch files
    ... "Giuseppe" wrote: ... I was looking on how to do a batch file that created a folder with the ... You will find a lot of help built into the respective commands, ... Now try this: echo %year%-%month%-%day% ...
    (microsoft.public.windows.server.scripting)
  • Re: Environmental Variables batch files
    ... "Pegasus (MVP)" wrote: ... I was looking on how to do a batch file that created a folder with the ... You will find a lot of help built into the respective commands, ... Now try this: echo %year%-%month%-%day% ...
    (microsoft.public.windows.server.scripting)
  • got it!
    ... set up a batch file in the winnt folder so i could run a series of commands ... You also have to lower the version of the policy, ... >> (you can use the scheduler to schedule remotely): ...
    (microsoft.public.win2000.security)