Missing conjunction


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Missing conjunction
# 1  
Old 12-20-2010
Missing conjunction

Hi Gurus,

I have prepared a script to find the log file based on a date range defined in one of the environment files, archive the logs files and move them to a particular directory.

Below is the script:

Code:
. /home/.profile

. /home/.inf_env

logfile=$scripts_path/Logs/file_archive1.log

# Get the list of Integration Services

infacmd.sh listservices -dn $INFA_DOMAIN -un Administrator -st IS | sed '$d' > temp_fa.txt

echo "List of Integration Services:\n`cat temp_fa.txt`" >> $logfile

while read line

   do
           echo "Integration Service Name =\n" $line >> $logfile


         ISPath=$(grep $line < $scripts_path/integration_services.txt | awk '{print$2}')

              echo "Integration Service path:"$ISPath

   cd $ISPath/SessLogs

   counter=`find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time | wc -l`

     if [ ${counter} -eq 0 ]; then

        echo "Session Logs not found for the date range" >> $logfile

     else
       
    find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time -exec ls -l {} \; | gtar cvf SessLogs`date +%Y%m%d` SessLogs`date +%Y%m%d`| compress -
    v SessLogs`date +%Y%m%d`>> $logfile

        echo "Number of SessionLogs deleted:"`find . -name "*.bin" -type f +$file_arch_st_time -mtime -$file_arch_end_time -exec ls -l {} \; | wc -l` >> $logfile

       #find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time -exec rm {} \;

           mv -f SessLogs`date +%Y%m%d`.Z $ISPath/Archive

               RC=$?
                           if [ $RC != 0 ]; then
                                   echo "Failed to move the compressed file" >> $logfile
                           fi
     fi

    done < temp_fa.txt

But when I try to run this script, i am getting the following error:

Code:
gtar: SessLogs20101220: file is the archive; not dumped
find: missing conjunction

I am clueless about these 2 errors. Please let me know the issue with the script.

Regards,
Sam
# 2  
Old 12-20-2010
Code:
echo "Number of SessionLogs deleted:"`find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time -exec ls -l {} \; | wc -l` >> $logfile

You missed -mtime in your code
# 3  
Old 12-20-2010
The problem with your tar command is that
Code:
gtar cvf SessLogs`date +%Y%m%d` SessLogs`date +%Y%m%d`

Should just be
Code:
gtar cvf SessLogs`date +%Y%m%d`

However, I can't see what you want to achieve by piping a long directory listing into the standard input of tar. Perhaps you should be using cpio instead of tar and using 'find ... -print' instead of 'find ... -exec ls -l {} \;'
# 4  
Old 12-20-2010
Quote:
find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time

find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time -exec ls -l {} \;

find . -name "*.bin" -type f -mtime +$file_arch_st_time -mtime -$file_arch_end_time -exec ls -l {} \;

All three of these "find" make no sense even though they are not a syntax error (after syntax correction).
With respect to the values if $file_arch_st_time and $file_arch_end_time what (in words) are the commands intended to do?


Quote:
find the log file based on a date range defined in one of the environment files
Does not define the range.
# 5  
Old 12-20-2010
Thanks Anurag for your suggestion. It fixed the problem. But now i run into a different issue. Somehow i am not able to uncompress/untar the compressed file.

It gives the below error.
Code:
file is the archive; not dumped

Kevin,

Is it because of the issue you highlighted?

Also I read in one of the article that the cpio has a limitation of max 2 GB for each file. But my files might be more than 2 GB in some scenarios.

Sam

---------- Post updated at 04:44 PM ---------- Previous update was at 04:40 PM ----------

@methyl

Suppose, I defined the values for below variables in my environment file as

file_arch_st_time=7
file_arch_end_time=14

then the script substitutes the above values and finds the files between 7 and 14 days. Please let me know if this incorrect way of writing the script

Regards,
Sam

Last edited by svajhala; 12-20-2010 at 05:53 PM..
# 6  
Old 12-20-2010
Your gtar command says:
Code:
gtar cvf filename filename

Which means create a tar archive of the file called filename and store it in the file called filename, ie. the same file, so you get the error 'file is the archive.'

The 2GB file size limit is a limit of 32 bit versions of linux, not cpio, so you would get the same limit with tar. However, if you use compression, as you are trying to do, it would be the compressed file that would need to be less than 2GB. By the way, if you want to create a compressed tar file you would use:
Code:
gtar cvzf filename

You don't pipe tar to compress, you can pipe cpio to compress.
# 7  
Old 12-20-2010
OK. Thanks. But when I use the below statement,

Code:
find . -name "*.bin" -type f -mtime +7 -mtime -14 | gtar cvzf SessLogs`date +%Y%m%d`.tar

I am getting the following error.

Code:
gtar: Cowardly refusing to create an empty archive
Try `gtar --help' or `gtar --usage' for more information.

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Yum - resolving missing dependencies that are not missing

I am trying to install VirtualBox on RHEL 5 but I need the 32 bit version for 32 bit Windows. When I run yum I get the following: sudo yum localinstall /auto/spvtg-it/spvss-migration/Software/VirtualBox-4.3-4.3.2_90405_el6-1.i686.rpm Loaded plugins: fastestmirror Setting up Local Package... (13 Replies)
Discussion started by: gw1500se
13 Replies

2. SuSE

How to resolve missing missing dependencies with opensuse 11.3 and 12.3?

Hello, This is a programming question as well as a suse question, so let me know if you think I should post this in programming. I have an application that I compiled under opensuse 12.2 using g77-3.3/g++3.3. The program compiles and runs just fine. I gave the application to a colleague who... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

3. UNIX for Dummies Questions & Answers

Nohup in conjunction with time

hi, if I exectute "nohup time ls -1" I get the following output $ nohup time ls -1 file_1 file_2 file_3 file_4 file_5 0.000u 0.001s 0:00.00 0.0% 0+0k 0+0io 0pf+0w This is all OK. But if I want to capture this whole output in to a text file I would want to use something like ... (1 Reply)
Discussion started by: BearCheese
1 Replies

4. Shell Programming and Scripting

[: missing `]'

Hi, I am getting this error while running the following code. i=`awk '{print $2}' test1.txt` j=`awk '{print $4}' test1.txt` k=`awk '{print $6}' test1.txt` if ; then echo "Up." else echo "down" fi rm -f test.txt test1.txt error is this: line 12: ' Please suggest. (2 Replies)
Discussion started by: arijitsaha
2 Replies

5. Shell Programming and Scripting

Problem with date in conjunction with cut?

I got rather bored so i decided to create a script that creates a countdown, and shows hours:minutes:seconds till that time. It works fine until the seconds of the actual time reaches 8, then it tries to use it to work out the difference as in "SECONDDIFF=$" Here's my code where I get the... (12 Replies)
Discussion started by: DuskFall
12 Replies

6. Shell Programming and Scripting

How to go about Using a "Validate an IP script" in conjunction with Logfile?

Hi, so I have been trying to write a shell script to go through a log file and through that, generate another file with all the Valid IP addresses it finds. So there's the complication that there could be incomplete or invalid data which would disqualify it from making my "Valid IPs" file I need... (3 Replies)
Discussion started by: shellcow
3 Replies

7. Shell Programming and Scripting

conjunction two files

I need to your help. I want write a script search for rows in file1 if exist in file2 it will print rows from file2 else it will print rows from file1 with out any duplicate ... (4 Replies)
Discussion started by: kmuqalled
4 Replies

8. UNIX for Dummies Questions & Answers

Missing Package

Hi All, I have a server running SunOS 5.9, on this I need to install Oracle 10g; however the installer returns ERROR: Unable to convert from "UTF-8" to "646" for NLS! Did some digging around and found that I need the SUNWuiu8 package. However I'm not sure where I can download the... (1 Reply)
Discussion started by: Zak
1 Replies

9. Shell Programming and Scripting

what am I missing?

I have the following portion of a script Check() { echo "\n\nChecking that all constraints are Enabled" echo "..." sleep 2 CHECK_COUNT='sqlplus -s $1 <<-EOSQL4 set feed off pause off pages 0 head off; set linesize 150 echo off; select count(*) from user_constraints where... (4 Replies)
Discussion started by: Zelp
4 Replies
Login or Register to Ask a Question