The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list tunable parameters and its values (Solaris 8) danielsf SUN Solaris 2 01-08-2009 05:41 AM
Shell program to accept multiple request at the same time tcskurra Shell Programming and Scripting 3 06-05-2008 11:29 AM
How to store query multiple result in shell script variable(Array) div_Neev Shell Programming and Scripting 4 11-06-2007 08:10 PM
Grep on multiple parameters kingofprussia UNIX for Dummies Questions & Answers 5 05-21-2007 08:31 AM
Modify semaphores parameters on Linux annececile UNIX for Dummies Questions & Answers 6 01-31-2002 07:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-30-2008
Sammy Sammy is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1
Request to modify script to list multiple parameters for V_fieldid variable

I am posting a script below which essentially excutes the following functions in the described order.

1) From a source directory pools together three files generated by system logs for each user session, tar's these files and archives them as a log set in a destination directory and these removes the three files which were zipped and archived from the source directory.

2) The zipped and archived logset will be tagged as sudosh.actual date the files were created (mm/dd/yyyy) format .hostname .tar

3) The script is designed to clear a backlog of files created in source directory of each box.

4) If there were no user log files on a particular day then a zero tar logset is created with a tag .nologs.sudosh. date (mm/dd/yyyy) .hostname.tar and archived in destination directory.

Note : Th script works fine when there are no log files and just files generated by one user session which gives only one "v_fileid" parameter to the script.

However if there are multiple user sessions generating multiple log files on a a particular day it creates multiple parameters for teh V-fileid variable which the script is unable to process and denotes an error that files could not be opened for that particular day .

can someone assist me by showing how I can update the "v_fileid" variable to accept a list or multiple parameters in addition to zero and one parameter for a particular day and process the rest of the script to accomplish the tasks noted above.

I believe there may be a small syntax modification that can be done to the existing script to make it accept and work in the scenario where there are more several files created in the source directory because of multiple user sessions generating a list of parameters for the v_fileid variable in the script noted below.

Request urgent assistance in making this script work when zero, one or multiple parameters exist for a given day. Thank you.

#! /usr/bin/ksh
--cd /var/adm/sammy/sourcedir
srcdir=/home/sam/srcdircat
trgdir=/home/sammy/trgdir

cd $srcdir

h=$(hostname)
--ts=`date '+%m%d%Y'`

v_mon=Jan
v_day=01
v_year=`date '+%Y'`

x=0
while [ $x -le 90 ]
do

echo x is $x

case $v_mon in
Jan) v_file_mon=01;;
Feb) v_file_mon=02;;
Mar) v_file_mon=03;;
Apr) v_file_mon=04;;
May) v_file_mon=05;;
Jun) v_file_mon=06;;
Jul) v_file_mon=07;;
Aug) v_file_mon=08;;
Sep) v_file_mon=09;;
Oct) v_file_mon=10;;
Nov) v_file_mon=11;;
Dec) v_file_mon=12;;
*) exit 1;;
esac


ts=$v_file_mon$v_day$v_year

echo ts is $ts

v_fileid=`ls -l |awk '$6 == "'$v_mon'" && $7 == "'$v_day'" { print $9 }'|awk -F"-" '{ print $4 }'|sort -u`

echo v_fileid is $v_fileid

if [ "$v_fileid" ]; then

echo "files exist, proceed to processing"

v_files=`ls -l|awk '{ print $9 }'|grep $v_fileid`
--v_file_month=`ls -l|grep $i|awk '{ print $6 }'|sort -u`
--v_file_day=`ls -l|grep $i|awk '{ print $7 }'|sort -u`
echo files are $v_files
tslog=sudosh.$h.$ts
tar -cvf $tslog.tar $v_files
tar_status=`echo $?`

if [ $tar_status -eq 0 ]; then
echo "tar file created successfully"
mv $srcdir/$tslog.tar $trgdir/$tslog.tar
rm $v_files
else
echo "tar file creation failed"
fi



else
echo "no file present"
logfile=nologs.sudosh.$h.$ts.txt
tslog=nologs.sudosh.$h.$ts
echo "no file today $ts" >>$logfile
tar -cvf $tslog.tar $logfile
mv $srcdir/$tslog.tar $trgdir/$tslog.tar
rm $logfile

fi

if [ "$v_mon" == "Jan" ] && [ "$v_day" == "31" ]; then
v_mon=Feb
v_day=01
elif [ "$v_mon" == "Feb" ] && [ "$v_day" == "29" ]; then
v_mon=Mar
v_day=01
else
v_day=`expr $v_day + 1`
if [ $v_day -le 9 ]; then
v_day=0`echo $v_day`
fi
fi

x=`expr $x + 1`
echo x is $x
done
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0