Re: [LUNI] scripting...

From: David Rock (rockdw@bigfoot.com)
Date: Fri Mar 23 2001 - 18:46:02 CST

  • Next message: Douglas Trainor: "[LUNI] DSL alternative from Sprint"

    On Fri, Mar 23, 2001 at 08:31:31AM -0800, Andrew Close wrote:
    > luni's
    >

    First off, what shell are you using? I will assume bash unless you say
    otherwise.

    > i'm doing:
    >
    > <shutdown script stuff...>
    >
    > TIMESTAMP = `date '+%m/%d/%y_%H:%M:%S'`
    >
    > mv /XXX/tomcat/logs/logfile
    > /XXX/tomcat/logs/RotatedLogs/logfile. + TIMESTAMP
    >
    > this gives me a:
    > mv: when moving multiple files, last argument must be
    > a directory
    > Try `mv --help' for more information.

    to define a variable in bash, you need to have no spaces. So when you define
    the timestamp variable, it looks like this (BTW, I use $(command) instead of
    the backquotes in bash, mostly because I think it's easier to see):

    TIMESTAMP=$(date '+%m/%d/%y_%H:%M:%S')

    When you use the variable, put the "$" in front of it to expand it in the
    script (again, no spaces and no plus sign):

    mv /XXX/tomcat/logs/logfile /XXX/tomcat/logs/RotatedLogs/logfile.$TIMESTAMP

    The problem with your original mv line is you have the wrong number of
    operators for the mv command. It thinks you are trying to use TIMESTAMP
    as a directory location to move to.

    > and how do i use environment variables within the
    > script? instead of typing out:
    >
    > mv /XXX/tomcat/logs/logfile ...
    >
    > i want to use $TOMCAT_HOME which is set up to point at
    > tomcats home dir: /XXX/tomcat
    >
    > then i could type:
    > mv $TOMCAT_HOME/logs/logfile

    you may need to export the TOMCAT_HOME variable. Where are you defining it?
    In your startup files or in the script somewhere? If it's in the script, it
    should work just fine by using $TOMCAT_HOME, if not, export it like this at
    the time it's defined:

    export TOMCAT_HOME=/XXX/tomcat

    > ps: where can i get some quick and dirty lessons on
    > shell scripting for bash online?
    >

    There is a TON of stuff in the bash man pages. Also, some distros provide
    a bash-doc package that has even more stuff.

    -- 
    David Rock
    rockdw@bigfoot.com
    

    -----BEGIN GEEK CODE BLOCK----- version 3.12 GIT$>CS$ d-(?) s+:+>+: a- C++$ UL++>++++ P+ L++(+++)>++++$ E---(-) W(+)-- N++ o? K- w--()$ O+ M-@ V-- PS PE Y PGP++@ t++@ 5++@ X- R(+++) tv(+) b+ DI++ D++ G e+(*)>++++ h--- r+++ y+++ -----END GEEK CODE BLOCK-----


    • application/pgp-signature attachment: stored
    -=- Linux Users Of Northern Illinois: General Discussion Mailing list. For unsubscription, archives, and announcements only see http://luni.org



    This archive was generated by hypermail 2b29 : Fri Mar 23 2001 - 18:49:12 CST

  •