Sponsored Content
Operating Systems OS X (Apple) Check file sequence script not working. Need help. Post 302516866 by Corona688 on Monday 25th of April 2011 12:42:14 PM
Old 04-25-2011
You agreed not to bump posts when you registered.

You're certainly not running it in bash, not sure why you mention it at all.

I see nothing in that code which would have ever added leading zeroes to your strings.

There's plenty of things in your script which in a bourne shell would be "useless use of ls *" and the like but in csh these constructs may actually be necessary...

But whether your shell be csh or zsh or whatever you can't exit -1, that value's nonsensical. It has to be a positive value between 0-255 inclusive.

Most of us aren't too fluent in CSH for a variety of reasons which cts already linked. You'd do better to learn a real scripting language. Trying a solution in bash for you.

I surmise that the version of csh you used to use had these :r etc string operations. Mine certainly doesn't and may be what broke down when you brought this script over.

---------- Post updated at 10:42 AM ---------- Previous update was at 09:49 AM ----------

Code:
#!/bin/bash

MAX=0   MIN=999999      TOTAL=0

# Don't have functions in csh.  Can't redirect to stderr properly either.
function die    # Print an error message to stderr, return 1
{
        echo "$@" >&2   ;       exit 1
}

[ "$#" -ne 1 ] && die "Usage: $0 <prefix>"      # Die unless exactly 1 arg

# Loop over all files.  (NOTE: May exceed argmax in other shells)
for I in ${1}.[0-9][0-9][0-9][0-9][0-9].dpx
do
        [ -f "$I" ] || die "No files found for prefix $1"
        # csh doesn't have a proper 'read'.  You can read from your TTY, that's it
        IFS="." read G C G <<< "$I"     # Extract number from string

        # Strip all leading zeroes
        while [ "${C:0:1}" == "0" ] && [ ! -z "${C:1:1}" ]
        do
                C="${C##0}"
        done

        [ "$C" -gt "$MAX" ] && MAX=$C   # Update max
        [ "$C" -lt "$MIN" ] && MIN=$C   # Update min
        ((TOTAL++))
done

for ((N=MIN; N<=MAX; N++))
do
        FILE=$(printf "%s.%05d.%s" "$1" $N "dpx")

        [ -f "$FILE" ] || echo "$FILE missing" >&2
done

[ "$TOTAL" -lt "$(((MAX-MIN)+1))" ] &&
        die "$((((MAX-MIN-TOTAL)+1))) files missing"

printf "No files missing in %s.%05d.dpx - %s.%05d.dpx\n" $1 $MIN $1 $MAX >&2

exit 0


Last edited by Corona688; 04-25-2011 at 05:28 PM.. Reason: Moved TOTAL++ to simplify code
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies

2. Shell Programming and Scripting

help - script can check jump sequence?

Hi, if I have a lot of files like (AABBCC0010, AABBCC0011, AABBCC0012....AABBCC1000), can I write a small script to check any sequence number jump and show me the result which sequence number? #The first sequence may start from 0010 or 0101... :confused: Thank you!! (10 Replies)
Discussion started by: happyv
10 Replies

3. Shell Programming and Scripting

Script to check file sequence

Hi everyone, I need help in creating a script that would check if the file sequence is in order in a particular directory. These are log files that are generated throughout the day. Example of the file name will be, ABC01_YYMMDDHHMM###### (ABC01_0904161829000001) Sometimes the file... (4 Replies)
Discussion started by: kumaran21
4 Replies

4. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

5. Shell Programming and Scripting

Check Sequence

* Expiry DATE: * Address1: Address2: Address3: Address4: Address5: * PO_ref_number: aadad HolderId_1: HolderId_2: HolderId_3: HolderId_4: * adad: 00000 ada: 00000 adad: RANDOM adad: RANDOM ****************************** (4 Replies)
Discussion started by: arunshankar.c
4 Replies

6. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

7. Shell Programming and Scripting

How to check missing sequence?

I want to listed files every hours and check the missing sequence my file format is CV.020220131430.txt CV.020220131440.txt CV.020220131450.txt CV.ddmmyyhhm.txt how to check if i have missing files in sequence .. thanks (3 Replies)
Discussion started by: before4
3 Replies

8. Solaris

Escape Sequence for Capital Letters Input at Shell Not Working

Hello, I am running Solaris 8. When issuing the command "stty lcase" all text which is output to the terminal are capitalized. Letters that are supposed to be capitals are preceded by a backslash during output. All text which is input is converted to lower case. This is the expected behaviour... (5 Replies)
Discussion started by: rstor
5 Replies

9. Shell Programming and Scripting

Shell script check syntax not working ...

Hello i have question that i want check syntax from my script shell with sh -n filename but it's not show something even i have wrong syntax in my file. why can this happened or any other way to check it? i use on header of file : #!/bin/sh thx before :) (7 Replies)
Discussion started by: Gochengz
7 Replies

10. Shell Programming and Scripting

To check the missing file based on sequence number.

Hi All, I have a requirement that i need to list only the missing sequences with a unix script. For Example: Input: FILE_001.txt FILE_002.txt FILE_005.txt FILE_006.txt FILE_008.txt FILE_009.txt FILE_010.txt FILE_014.txt Output: FILE_003.txt FILE_004.txt FILE_007.txt FILE_011.txt... (5 Replies)
Discussion started by: Arun1992
5 Replies
RAN2TIFF(1)						      General Commands Manual						       RAN2TIFF(1)

NAME
       ran2tiff - expose and convert a RADIANCE animation to TIFF frames

SYNOPSIS
       ran2tiff [ -W prev_frame_wt ][ -H histo ][ -D dir ] [ pcond opts ] [ ra_tiff opts ] frame1.hdr frame2.hdr ..

DESCRIPTION
       Ran2tiff  takes	an animated sequence of Radiance pictures and converts them by calling pcond(1) and ra_tiff(1) in such a way that exposure
       changes gradually from one frame to the next.  It accomplishes this by computing a histogram for each image and blending it with a weighted
       histogram  from the previous frame, where the weight is set by the -W option, or 0.9 by default.  A value of 0.5 would mean that the previ-
       ous frame carries 1/2 the weight of the current one, and the frame before that 1/4, 1/8 before that, and so on.

       The -H option specifies a histogram file to be used to ensure continuous exposure between the current sequence and one before it.   If  the
       file  does not exist, it will be created at the end of the conversion.  If it does exist, its contents will be used as the histogram at the
       end of the previous sequence.

       The -D option may be used to specify an output directory for the resulting TIFF frames.	Otherwise, the current	directory  will  be  used.
       The output file names will correspond to the input names, but with a ".tif" suffix.

       Ran2tiff  also  accepts the standard options for pcond and ra_tiff, though output to LogLuv TIFF formats is not supported.  (There would be
       no point in adjusting the exposure if the output were HDR.)

EXAMPLE
       To convert a sequence of frames using a rapid human exposure response and LZW compression on the output:

	 ran2tiff -W 0.7 -h -z frame*.hdr

       Similar to fieldcomb(1), this program works well with the "TRANSFER" facility of ranimate(1).

AUTHOR
       Greg Ward

SEE ALSO
       fieldcomb(1), getinfo(1), pcond(1), pfilt(1), phisto(1), ra_tiff(1), ranimate(1), rpict(1)

RADIANCE							     9/16/2005							       RAN2TIFF(1)
All times are GMT -4. The time now is 09:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy