UNIX shell script for loop issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX shell script for loop issue
# 1  
Old 07-05-2013
UNIX shell script for loop issue

Guys,

Please help on the below.

Code:
 sample.prm
 
/u/test/:
 mail=123@gmail.com
 purgedays=30
 zipdays=7
 purgefile=log.gz
 zipfile=log
 
/u/test/:
 mail=123@gmail.com
 purgedays=30
 purgefile=txt.gz
 zipfile=txt
 zipdays=7

Code:
 
sample.cfg
purge_path="/u/test/"
parmfile=sample.prm
log=sample.log

Code:
sample.sh
#!/bin/sh
#here cfg=
. $cfg
 
for VAR in $purge_path    # was $pruge_path
do
   mail_id=`stanzaget ${parm_file} ${VAR} mailid`
   purge_days=`stanzaget ${parm_file} ${VAR} purgedays`
   zip_days=`stanzaget ${parm_file} ${VAR} zipdays`
   purge_file=`stanzaget ${parm_file} ${VAR} purgefile`
   zip_file=`stanzaget ${parm_file} ${VAR} zipfile`
 
   find $VAR -type f -mtime +$zip_days -name "*zip_file" -exec ls -la {} \;
 
   find $VAR -type f -mtime +$purge_days -name "*purge_file" -exec ls -la {} \;
 
done

when the above script runs, its taking the first stanza values from sample.prm.. Its not taking the second stanza since both are same path(/u/test/)
i want both the paths to be looped while the program is running.
Can anyone please help me on this..

Thanks
Moderator's Comments:
Mod Comment This is a duplicate of another thread.

Last edited by Don Cragun; 07-05-2013 at 06:03 AM.. Reason: Closing duplicate thread.
# 2  
Old 07-05-2013
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Bash Script for Dice Game; Issue with if...else loop to verify user guess is within range

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have written a script for a dice game that: (1) tells user that each of the 2 die are 6 sided (Spots=6); (2)... (3 Replies)
Discussion started by: LaurenRose
3 Replies

2. Shell Programming and Scripting

Issue with SQL UNIX shell script -

Hi all I am writing a shell script which will run a select query from a table . If the ouput is not 500 - then send a email to the team saying there is a error . But i am not sure how to redirect this output of the select query to the log file - #!/bin/ksh sqlplus /nolog conect... (1 Reply)
Discussion started by: honey26
1 Replies

3. Shell Programming and Scripting

How to get the for loop output from a remote server in UNIX shell scripting?

Hi, I am using ksh , when i try to use for loop i am getting the expected output. $for variable in $(ps -fu user | grep -i something/ | grep -i something | grep -v grep | awk '{print $2}');do > grep $variable /tmp/some_path/*/* > done when tried the below to remote server, getting... (4 Replies)
Discussion started by: karthikram
4 Replies

4. Shell Programming and Scripting

[Solved] Issue with using for loop as for in {2..6} in korn shell

Hi i have to cut columns 2 to 6 from a file and assign it to arrays , The following code works for ctcol in 2 3 4 5 6; do set -A a$ctcol $(cut -d, -f $ctcol test_file) done how ever this does not work for ctcol in {2..6}; do set -A a$ctcol $(cut -d, -f $ctcol test_file)... (4 Replies)
Discussion started by: 100bees
4 Replies

5. Shell Programming and Scripting

UNIX shell script - cut specified line and perform loop

Guys, I have a requirement as below. consider,if i use df command, its getting the below output. file system kbytes used avail %used Mounted on /dev/sample/ 45765 40000 5765 50% / /dev/filesys/ 30000 20000 1000 80% /u .... .... Now i wanted to cut the /u... (11 Replies)
Discussion started by: AraR87
11 Replies

6. Shell Programming and Scripting

Issue with for loop, help me with a script

Hi, i have to compare the second column of the each line of the file1.csv with the data in file2.csv file and replace if a match is found. below is data. Can someone please help me with a script. so output file should lokk like below (7 Replies)
Discussion started by: JSKOBS
7 Replies

7. Shell Programming and Scripting

Unix Shell basic loop massive n00b

hey guys I would really appreciate some help, i need to do a project for a job that requires minimal UNIX scripting and im REALLY stuck basically Im stuck at what i believe is something really simple but i just dont have a clue how to do it efficiently and properly and i REALLY appreciate some... (16 Replies)
Discussion started by: thurft
16 Replies

8. Shell Programming and Scripting

Unix Shell Script to loop over Directory and send Filesname as parameters

Hi there I'm new to UNIX scripting; I’m stuck with the following I have an Oracle SQL script that takes three parameters 1- File Name 2- File Path 3- File creation date Under UNIX I have a folder where files will be placed frequently and I need to upload those files to Oracle, what I need... (3 Replies)
Discussion started by: windjashi
3 Replies

9. Shell Programming and Scripting

Unix Korn Shell Array Issue (SunOS)

Hello, I'm currently messing around with arrays for the first time in scripting (Unix Korn Shell). All I'm trying to do right now before I make things complicated is read through and print out to screen whether the read file is or is not a directory. Here is my directory: ls -l total... (5 Replies)
Discussion started by: Janus
5 Replies

10. UNIX for Advanced & Expert Users

Unix Shell script FTP Issue

Hi All We have a number of FTP Shell scripts running every day on a scheduled basis. The issue we have is if the host connection is not available after a little while ftp times out and the script hangs as the shell returns to the ftp> prompt waiting for input from a user. Any ideas how... (2 Replies)
Discussion started by: mlucas
2 Replies
Login or Register to Ask a Question