Writing scripts in Linux - Redhat

This is a discussion on Writing scripts in Linux - Redhat ; Hi Guys, Generally it is considered hard to write scripts. But it's not that difficult. Here is an interesting article which explains how to write scripts in a very simple way. A must read http://www.knowurtech.com/linux/writing_scripts.html In general also i found ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Writing scripts in Linux

  1. Writing scripts in Linux



    Hi Guys,
    Generally it is considered hard to write scripts. But it's not that
    difficult. Here is an interesting article which

    explains how to write scripts in a very simple way. A must read

    http://www.knowurtech.com/linux/writing_scripts.html

    In general also i found this site quite interesting.
    Cheers!!
    Dinesh


  2. Re: Writing scripts in Linux

    Cisco_King writes:

    > Hi Guys,
    > Generally it is considered hard to write scripts. But it's not that
    > difficult. Here is an interesting article which
    >
    > explains how to write scripts in a very simple way. A must read
    >
    > http://www.knowurtech.com/linux/writing_scripts.html
    >
    > In general also i found this site quite interesting.


    Really?

    Learn to write scripts as root,
    what a concept.

    Lots of errors there too.

  3. Re: Writing scripts in Linux

    On Mon, 15 Oct 2007, in the Usenet newsgroup alt.os.linux.redhat, in article
    , Dan Espen wrote:

    >Cisco_King writes:


    [luser spam deleted]

    >Really?


    Oh, yes - our little spammer knows all kinds of interesting BS.

    Writing scripts in Linux Cisco_King
    Mon, 15 Oct 2007 04:45:15 -0700 alt.os.linux.redhat
    <1192448715.626193.186100@v23g2000prn.googlegroups. com>

    Using Linux as a router Cisco_King
    Sun, 14 Oct 2007 08:07:48 -0700 comp.os.linux.networking
    <1192374468.990383.237160@q3g2000prf.googlegroups.c om>

    Writing scripts in Linux Cisco_King
    Mon, 15 Oct 2007 04:42:24 -0700 comp.os.linux.setup
    <1192448544.561531.172830@v23g2000prn.googlegroups. com>

    Writing scripts in Linux Cisco_King
    Mon, 15 Oct 2007 04:45:06 -0700 comp.os.linux.setup
    <1192448706.160004.7780@i13g2000prf.googlegroups.co m>

    Enabling SNMP on checkpoint Cisco_King
    Sun, 14 Oct 2007 07:38:34 -0700 comp.security.firewalls
    <1192372714.182949.200860@i13g2000prf.googlegroups. com>

    Writing scripts in Linux Cisco_King
    Mon, 15 Oct 2007 04:45:11 -0700 linux.redhat
    <1192448711.171350.154210@t8g2000prg.googlegroups.c om>

    There could be more, but I'm killfiling googlegroups.com posts in a
    number of the newsgroups I try to scan daily. It cuts down on the spam
    quite a bit.

    >Learn to write scripts as root,
    >what a concept.


    Some people want to display to the world that they have no knowledge of
    anything, but DESPERATELY need suckers to so see his web site where he
    can demonstrate his stupidity. Aren't you impressed? He just registered
    the domain last month, and fortunately chose a web-hosting service that
    is in a lot of blocklists. Further evidence of his skills.

    >Lots of errors there too.


    Well, what do you expect of a windoze wanker?

    Old guy

  4. Re: Writing scripts in Linux

    On Mon, 15 Oct 2007 09:32:33 -0400, Dan Espen wrote:

    > Cisco_King writes:
    > ....blatant attempt to increase hits to his own website deleted ...
    >



    > Really?
    >
    > Learn to write scripts as root,
    > what a concept.
    >
    > Lots of errors there too.


    Okay, I'm a bit new to shell scripting but learning. What's wrong with
    writing a shell script as root so long as the script does not have root
    privileges itself? There was very little about this in the 3 or 4 books I
    have been using to learn shell scripting, so I'm wondering if I (or they)
    missed something. No, I won't go to Dinesh's site that shall remain
    nameless to find out! Thanks ...

    Rich

  5. Re: Writing scripts in Linux

    On Sun, 21 Oct 2007 23:02:58 GMT, Rich Leitner wrote:
    >
    > Okay, I'm a bit new to shell scripting but learning. What's wrong with
    > writing a shell script as root so long as the script does not have root
    > privileges itself?



    Shell scripts execute with the privs of the user running them.

  6. Re: Writing scripts in Linux

    Rich Leitner writes:

    > On Mon, 15 Oct 2007 09:32:33 -0400, Dan Espen wrote:
    >
    >> Cisco_King writes:
    >> ....blatant attempt to increase hits to his own website deleted ...

    >
    >> Really?
    >>
    >> Learn to write scripts as root,
    >> what a concept.
    >>
    >> Lots of errors there too.

    >
    > Okay, I'm a bit new to shell scripting but learning. What's wrong with
    > writing a shell script as root so long as the script does not have root
    > privileges itself?


    Unless you are perfect, your scripts will have errors.
    If you write and test them as root, the simplest coding error
    could wipe your whole system.

    Write scripts as a regular user and never test scripts with live
    data. Only after you are sure it is working do you run it with
    live data or as root.

  7. Re: Writing scripts in Linux

    Bit Twister wrote:
    > On Sun, 21 Oct 2007 23:02:58 GMT, Rich Leitner wrote:
    >> Okay, I'm a bit new to shell scripting but learning. What's wrong with
    >> writing a shell script as root so long as the script does not have root
    >> privileges itself?

    >
    >
    > Shell scripts execute with the privs of the user running them.


    If you are writing a script as root, and testing it as root, you need to
    be very careful, that is all.

    here is a VERY stupid example (please DO NOT run it as root - it will
    destroy your machine!!!!!!!!!!)

    #!/bin/sh
    TOPDIR="/"
    JUNKDIR1="junk-dir1"
    JUNKDIR2="junk-dir2"
    echo cleaning out junk-dir1 and junk-dir2
    rm -rf $TOPDIR/$JUNKDIR1/*
    rm -rf $TOPDIR/$JUNK_DIR2/*


    I WANTED to have the script delete everything under "/junk-dir1" &
    "/junk-dir2"

    Unfortunately, on the second rm line, I wrote:
    rm -rf $TOPDIR/$JUNK_DIR2/*

    when I MEANT to write
    rm -rf $TOPDIR/$JUNKDIR2/*

    The outcome is the command
    "rm -rf ///*" is run (which is the same as "rm -rf /*"

    This command deletes everything on your hard drive, and your system will
    stop working... for you, and everyone else.

    If you run that script as a regular user, it will start spewing messages
    like:
    rm: cannot remove directory `bin': Is a directory

    yes, eventually it will recursively works its way down to your home
    directory, and delete everything there... which would suck... but the
    machine is still up and running fine for everyone else.


    The "root" account can cause GLOBAL mistakes. A regular user can only
    cause LOCAL mistakes.


    --
    Alexander N. Spitzer
    Bonsai Bonanza
    http://www.BonsaiBonanza.com

  8. Re: Writing scripts in Linux

    On Mon, 22 Oct 2007 01:05:22 +0000, Bonsai Bonanza wrote:

    > Bit Twister wrote:
    >> On Sun, 21 Oct 2007 23:02:58 GMT, Rich Leitner wrote:
    >>> Okay, I'm a bit new to shell scripting but learning. What's wrong with
    >>> writing a shell script as root so long as the script does not have
    >>> root privileges itself?

    >>
    >>
    >> Shell scripts execute with the privs of the user running them.

    >
    > If you are writing a script as root, and testing it as root, you need to
    > be very careful, that is all.
    >
    > here is a VERY stupid example (please DO NOT run it as root - it will
    > destroy your machine!!!!!!!!!!)
    >
    > #!/bin/sh
    > TOPDIR="/"
    > JUNKDIR1="junk-dir1"
    > JUNKDIR2="junk-dir2"
    > echo cleaning out junk-dir1 and junk-dir2 rm -rf $TOPDIR/$JUNKDIR1/*
    > rm -rf $TOPDIR/$JUNK_DIR2/*
    >
    >
    > I WANTED to have the script delete everything under "/junk-dir1" &
    > "/junk-dir2"
    >
    > Unfortunately, on the second rm line, I wrote: rm -rf
    > $TOPDIR/$JUNK_DIR2/*
    >
    > when I MEANT to write
    > rm -rf $TOPDIR/$JUNKDIR2/*
    >
    > The outcome is the command
    > "rm -rf ///*" is run (which is the same as "rm -rf /*"
    >
    > This command deletes everything on your hard drive, and your system will
    > stop working... for you, and everyone else.
    >
    > If you run that script as a regular user, it will start spewing messages
    > like:
    > rm: cannot remove directory `bin': Is a directory
    >
    > yes, eventually it will recursively works its way down to your home
    > directory, and delete everything there... which would suck... but the
    > machine is still up and running fine for everyone else.
    >
    >
    > The "root" account can cause GLOBAL mistakes. A regular user can only
    > cause LOCAL mistakes.


    Okay, that makes good sense. I have a couple old experimental machines
    that I fool with, and I often sign on as root (against the conventional
    wisdom, I know!) because it's easier and I'm lazy, but I don't really
    worry about mucking them up. I'll keep that in mind for any important
    machines. Thanks...

    Rich

+ Reply to Thread