![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell program to accept multiple request at the same time | tcskurra | Shell Programming and Scripting | 3 | 06-05-2008 08:29 AM |
| list tunable parameters and its values (Solaris 8) | danielsf | SUN Solaris | 1 | 04-25-2008 09:56 AM |
| How to store query multiple result in shell script variable(Array) | div_Neev | Shell Programming and Scripting | 4 | 11-06-2007 04:10 PM |
| Grep on multiple parameters | kingofprussia | UNIX for Dummies Questions & Answers | 5 | 05-21-2007 05:31 AM |
| Modify semaphores parameters on Linux | annececile | UNIX for Dummies Questions & Answers | 6 | 01-31-2002 03:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |
| Forum Sponsor | ||
|
|