AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  AIX Shell script problem

    Posted Mon October 20, 2008 08:13 PM

    Originally posted by: chauhan_vin1


    Hi,

    I have a requirement to tar and then gzip a all the files under a certain directory starting with System*.

    These files needs to be put into a different directory ( Directory name should be timestamp).

    I am writing the below shell script but I am not getting the zipped file created under a directory , instead I am getting a file copied with the directory name as the name of the file.

    I think I am missing some thing due to which its not taking the directory name :

    Please see my script below :

    #!/bin/sh

    CUR_DATE=`date +%Y%m%d`

    CUR_TIME=`date +%H%M`

    mkdir "$CUR_DATE"-"$CUR_TIME"

    tar -cvf MDA_WPS_SysOutLogs.tar

    gzip MDA_WPS_SysOutLogs.tar

    cp MDA_WPS_SysOutLogs.tar.gz /wpsdev01/MDA/DevLogs/"$CUR_DATE"-"$CUR_TIME"/



    I want to get the same file MDA_WPS_SysOutLogs.tar.gz to be copied to /wpsdev01/MDA/DevLogs/20081020-1705/ directory , where '20081020-1705' is the Date-timestamp directory created by my script.

    but what I am getting is a gz file created under /wpsdev01/MDA/DevLogs/ with the mane as 20081020-1705

    Please help me with this :-

    Thanks,
    Vineet


  • 2.  Re: AIX Shell script problem

    Posted Tue October 21, 2008 01:17 PM

    Originally posted by: eventius


    Your tar command is missing arguments; you haven't given the names of any files to be tarred. From your discussion, perhaps somethings like:

    tar -cvf MDA_WPS_SysOutLogs.tar System*


  • 3.  Re: AIX Shell script problem

    Posted Tue October 21, 2008 01:17 PM

    Originally posted by: SystemAdmin


    Please check your script line :

    mkdir "$CUR_DATE"-"$CUR_TIME"

    This may not be creating dir. You might need to change it to :

    mkdir "$CUR_DATE-$CUR_TIME"

    Thanks
    Bharat Bhushan
    bharatbh@us.ibm.com