Sponsored Content
Full Discussion: Script Stuck In Loop
Top Forums Shell Programming and Scripting Script Stuck In Loop Post 302354844 by durden_tyler on Sunday 20th of September 2009 11:57:12 AM
Old 09-20-2009
As a side note, here's a different approach to tackle your problem that involves the use of the "seq" command. My setup is Bash on Linux, check your documentation to see if you have it.

Code:
$ 
$ cat -n testscr1.sh
     1    #!/bin/bash
     2    
     3    yr=$(date +%Y)
     4    mon=$(date +%m)
     5    dt=$(date +%d)
     6    
     7    if [ -d $yr/$mon ]; then
     8      for i in $(seq -w $dt -1 1)
     9      do
    10        if [ -d $yr/$mon/$i/products ]; then
    11          echo $yr/$mon/$i/products was found.
    12        else
    13          mkdir -p $yr/$mon/$i/products
    14          echo $yr/$mon/$i/products was not found. Created it.
    15        fi 
    16      done
    17    fi
    18    
$ 
$ 
$ find ./2009 | sort
./2009
./2009/09
./2009/09/04
./2009/09/04/products
./2009/09/13
./2009/09/15
./2009/09/15/products
./2009/09/19
$ 
$ # now run the script
$ ./testscr1.sh
2009/09/20/products was not found. Created it.
2009/09/19/products was not found. Created it.
2009/09/18/products was not found. Created it.
2009/09/17/products was not found. Created it.
2009/09/16/products was not found. Created it.
2009/09/15/products was found.
2009/09/14/products was not found. Created it.
2009/09/13/products was not found. Created it.
2009/09/12/products was not found. Created it.
2009/09/11/products was not found. Created it.
2009/09/10/products was not found. Created it.
2009/09/09/products was not found. Created it.
2009/09/08/products was not found. Created it.
2009/09/07/products was not found. Created it.
2009/09/06/products was not found. Created it.
2009/09/05/products was not found. Created it.
2009/09/04/products was found.
2009/09/03/products was not found. Created it.
2009/09/02/products was not found. Created it.
2009/09/01/products was not found. Created it.
$ 
$ # check the directories
$ find ./2009 | sort | grep products
./2009/09/01/products
./2009/09/02/products
./2009/09/03/products
./2009/09/04/products
./2009/09/05/products
./2009/09/06/products
./2009/09/07/products
./2009/09/08/products
./2009/09/09/products
./2009/09/10/products
./2009/09/11/products
./2009/09/12/products
./2009/09/13/products
./2009/09/14/products
./2009/09/15/products
./2009/09/16/products
./2009/09/17/products
./2009/09/18/products
./2009/09/19/products
./2009/09/20/products
$ 
$

tyler_durden
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

stuck on ksh script

hi, i need help to write script in korn shell that will display info. on system paging, system process table.system file table inf. thank you (1 Reply)
Discussion started by: neer45
1 Replies

2. UNIX for Dummies Questions & Answers

Menu function stuck in a loop?

I having problem when I call this cleanupmenu function within a script. It continuously loops and goes to selection * That wasn't a valid selection. I have to kill it everytime to stop it. What am I doing wrong. I use this function menu in several other scripts and I don't have this problem at... (2 Replies)
Discussion started by: darthur
2 Replies

3. Shell Programming and Scripting

simple script but am stuck

hey i am a bit stuck here. i just started work experience and i need to create a simple script which delete all files in a specify folder which are older then 2 days. :mad: i tried but it never works!!! anyone! i dont know much but unix since i mostly work on NT here but i dont wanna disapoint my... (2 Replies)
Discussion started by: GermanJulian
2 Replies

4. UNIX for Dummies Questions & Answers

stuck with a script

Hi There I am pretty new to UNIX and have only been using it from a basic point of view,I now want to start using it and learning more , have got a whole lot of books and documentation from the web and am slowly learning.I have written a get script in windows :- lcd E:\MAIN\PRO\FILES\MAINDB... (1 Reply)
Discussion started by: FOCKER
1 Replies

5. Shell Programming and Scripting

I am stuck in my script

Hi All I have script that find 777 dir with specific extension like .php .Now after finding all 777 directory i will place in httpd.conf using a directory directive ,Now i was not do that,if directory entry exitst in httpd.conf then script ignor it dont show me at stdout else if it dont find... (2 Replies)
Discussion started by: aliahsan81
2 Replies

6. Shell Programming and Scripting

perl loop keeps getting stuck

I am using a Perl script to open a series of files in a loop, separate the paragraph into lines, and output the lines into a new file. The code works perfectly fine, except when the source file is over a certain size the loop gets stuck and won’t move on to the next file. It still does what it is... (0 Replies)
Discussion started by: renthead720
0 Replies

7. Shell Programming and Scripting

Noob stuck - where do I put my loop

I'm a noob working on a script to take 3 user inputs. One of them is simply a variable: "poolname". The other 2 are cases: "groupa/groupb" and "enable/disable". "groupa" and "groupb" reference 2 files - groupa.txt or groupb.txt. These files simply consist of a list of server IP addresses and port... (2 Replies)
Discussion started by: *nixnoob
2 Replies

8. Shell Programming and Scripting

Stuck in this shell script - please help

hi: I'm trying to write a shell script that recognizes all .txt files in all the subdirectories in my current directory. Let's say that i have a directory called Applications which consists of many subdirectories on mnay levels. i want the shell script to look for all .txt files that exist... (14 Replies)
Discussion started by: miss_dodi
14 Replies

9. Shell Programming and Scripting

Error in script, STUCK :(

Hi All, I am beginner in scripting. I wrote a simple script to perform some task. It seem to have some error in command line, Kindly somebody help. Thanks #!/bin/bash date cd /home/poojasaxena/Desktop/CMS/script/DataMCMatch function pause(){ read -p "$*" } FILE=$1... (22 Replies)
Discussion started by: nrjrasaxena
22 Replies
setup.types(5)						      Easy Software Products						    setup.types(5)

NAME
setup.types - epm gui setup types file format. DESCRIPTION
The EPM setup program normally presents the user with a list of software products to install, which is called a "custom" software installa- tion. If a file called setup.types is present in the package directory, the user will instead be presented with a list of installation types. Each type has an associated product list which determines the products that are installed by default. If a type has no products associated with it, then it is treated as a custom installation and the user is presented with a list of packages to choose from. FILE FORMAT
The setup.types file is an ASCII text file consisting of type and product lines. Comments can be inserted by starting a line with the pound sign (#). Each installation type is defined by a line starting with the word TYPE. Products are defined by a line starting with the word INSTALL: TYPE Typical End-User Configuration INSTALL foo INSTALL foo-help TYPE Typical Developer Configuration INSTALL foo INSTALL foo-help INSTALL foo-devel INSTALL foo-examples TYPE Custom Configuration In the example above, three installation types are defined. Since the last type includes no products, the user will be presented with the full list of products to choose from. SEE ALSO
epm(1) - create software packages setup(1) - graphical setup program for the esp package manager COPYRIGHT
Copyright 1999-2007 by Easy Software Products, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 3 April 2006 ESP Package Manager setup.types(5)
All times are GMT -4. The time now is 11:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy